Know rowindex after filtering

  • Thread starter Thread starter Maileen
  • Start date Start date
M

Maileen

Hi,

Via VBA i filtered a sheet. Basically i should have as result only 1 row.

How can i know what is the rowindex (figure in the grey column margin
e.g : 873, or 34245,...) ?

thanks a lot,
Maileen
 
You have a reply to your post in .excel.
Hi,

Via VBA i filtered a sheet. Basically i should have as result only 1 row.

How can i know what is the rowindex (figure in the grey column margin
e.g : 873, or 34245,...) ?

thanks a lot,
Maileen
 
Assuming an autofilter
Dim rng as Range, rng1 as Range
set rng = Activesheet.autoFilter.Range
set rng = rng.offset(1,0).Resize(rng.rows.count-1,1)
On error resume next
set rng1 = rng.SpecialCells(xlvisible)
On Error goto 0
if not rng1 is nothing then
msgbox rng1(1).row
if rng1.count > 1 then msgbox "Multiple matches"
else
msgbox "No matches"
End if

Dim rng as Range, res as Variant
set rng = Activesheet.autoFilter.Range
set rng = rng.offset(1,0).Resize(rng.rows.count-1,1)
res = Application.Match(filtervalue,rng,0)
if not iserror(res) then
msgbox rng(res).Row
else
msgbox "No Matches"
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top