PDA

View Full Version : getting the row numbers of visible rows in an filtered selection



catgreen
10-02-2012, 05:48 AM
Hello all,

I have an Excel 2007 table which has 1500 rows and 60 columns of data. I use autofilter to filter out some information. For example I have filtered row 5, 12, 12 and 18. I select some rows (row 5 and 12)
I need a macro to find out the row numbers of these selected rows.

Thanks in advance.

catgreen

p45cal
10-02-2012, 06:28 AM
Sub blah()
For Each rw In Selection.Rows
If Not rw.Hidden Then MsgBox rw.Row
Next rw
End Sub

mikerickson
10-02-2012, 07:05 AM
I'm not sure what you want to do with those row numbers (put them in an array?, add them? ..), but some variation of this should work.

With Selection
If .Cells.Count = 1 Then
MsgBox .Address
Else
MsgBox .SpecialCells(xlCellTypeVisible).Address
End If
End With

catgreen
10-19-2012, 12:49 AM
Sorry for my late response, this solution worked problem free thank you. :hi: