Forum

Notifications
Clear all

Special Cells

3 Posts
2 Users
0 Reactions
109 Views
(@alberto)
Posts: 2
New Member
Topic starter
 

Hi there, need some help when using special cells.

In a set of data I'm using special cells type visible to select a filtered row that needs to be modified in an specific cell.

The code I'm using works well for every filter option except if the filter happens to be the first row after the header (heather in row 2:2, filter in row 3:3).

Can you please help. Confused

If ActiveSheet.FilterMode = True Then
'Select cell in 2nd row specific column
ActiveSheet.UsedRange.SpecialCells _
(xlCellTypeVisible).Areas(2).Columns(63).Cells(1, 1).Select

End If

 
Posted : 06/01/2017 7:12 am
(@sunnykow)
Posts: 1417
Noble Member
 

Hi Alberto

Give this a try.

Sub SelectVisibleCells()

Dim LastRow As Long
Dim LastColumn As Long

If ActiveSheet.FilterMode = True Then
LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
LastColumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
ActiveSheet.Cells(1, 1).Offset(1, 0).Resize(LastRow - 1, LastColumn).SpecialCells(xlCellTypeVisible).Select
End If
End Sub

 

Sunny

 
Posted : 06/01/2017 11:20 am
(@alberto)
Posts: 2
New Member
Topic starter
 

Thanks very much for your help Sunny Laugh

 
Posted : 07/01/2017 5:38 am
Share: