• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

I Need a code to know the row number from which the filter data is been shown.

sanmaya

New Member
HI All,

can anybody help me in this issue.

i need a a vba code which will tell me the row no from which the filter data is been shown in the sheet.


Thanks
 
Can you clarify what you mean? I don't understand what this means:

row no from which the filter data is been shown in the sheet.

a)You want the number of records found?

b)You want the row number of the headers?

c)You want the row number of a particular record that was found? If so, which record?

d)None of the above, please define.
 
Hi, sanmaya!

Taking a blind shot, if you asked for header row and filtered range try this:

Variable1 = Worksheets("XXX").AutoFilter.Range.Row

Variable2 = Worksheets("XXX").AutoFilter.Range.Address

Regards!
 
Hi Sanmaya ,


One way to find out the first data row in a filtered range is to see which is the first row which is not hidden.

[pre]
Code:
Sub FindFilterRow()
Dim w As Worksheet
Dim currentFiltRange As Range

Set w = Worksheets("Sheet1")
If w.AutoFilterMode Then
Set currentFiltRange = w.AutoFilter.Range
Number_of_rows = currentFiltRange.Rows.Count
For i = 2 To Number_of_rows
If Not currentFiltRange.Resize(1).Offset(i - 1, 0).EntireRow.Hidden Then
MsgBox "First row of filter is row number " & currentFiltRange.Row + i - 1
Exit For
End If
Next
End If
End Sub
[/pre]
Narayan
 
Back
Top