Select first visible cell under the header row after applying autofilter

awagdarikar

Board Regular
Joined
Jun 20, 2008
Messages
115
Hello,​

I need vba code to Select first visible cell below the header row after applying autofilter on column Q of the data. Can somebody help me on this?​

I tried​
http://www.mrexcel.com/forum/showthread.php?t=403989

but it does not work. Probably because column Q is filtered to show only blank cells,

Can somebody help me on this?

Thanks,
awagdarikar
 
Last edited:
Does this function help you any? It returns the row number of the first visible row in an autofiltered range (it returns 0 if all the cells in the autofiltered range are hidden).
Code:
Function GetFilteredRangeTopRow() As Long
  Dim HeaderRow As Long, LastFilterRow As Long
  On Error GoTo NoFilterOnSheet
  With ActiveSheet
    HeaderRow = .AutoFilter.Range(1).Row
    LastFilterRow = .Range(Split(.AutoFilter.Range.Address, ":")(1)).Row
    GetFilteredRangeTopRow = .Range(.Rows(HeaderRow + 1), .Rows(Rows.Count)).SpecialCells(xlCellTypeVisible)(1).Row
    If GetFilteredRangeTopRow = LastFilterRow + 1 Then GetFilteredRangeTopRow = 0
  End With
NoFilterOnSheet:
End Function

Neat! Just what I was looking for.
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Does this function help you any? It returns the row number of the first visible row in an autofiltered range (it returns 0 if all the cells in the autofiltered range are hidden).
Code:
Function GetFilteredRangeTopRow() As Long
  Dim HeaderRow As Long, LastFilterRow As Long
  On Error GoTo NoFilterOnSheet
  With ActiveSheet
    HeaderRow = .AutoFilter.Range(1).Row
    LastFilterRow = .Range(Split(.AutoFilter.Range.Address, ":")(1)).Row
    GetFilteredRangeTopRow = .Range(.Rows(HeaderRow + 1), .Rows(Rows.Count)).SpecialCells(xlCellTypeVisible)(1).Row
    If GetFilteredRangeTopRow = LastFilterRow + 1 Then GetFilteredRangeTopRow = 0
  End With
NoFilterOnSheet:
End Function
This is really good one! It helped me a lot!!

Thank you for posting this

Regards,
Vinmam
 
Upvote 0
Does this function help you any? It returns the row number of the first visible row in an autofiltered range (it returns 0 if all the cells in the autofiltered range are hidden).
Code:
Function GetFilteredRangeTopRow() As Long
  Dim HeaderRow As Long, LastFilterRow As Long
  On Error GoTo NoFilterOnSheet
  With ActiveSheet
    HeaderRow = .AutoFilter.Range(1).Row
    LastFilterRow = .Range(Split(.AutoFilter.Range.Address, ":")(1)).Row
    GetFilteredRangeTopRow = .Range(.Rows(HeaderRow + 1), .Rows(Rows.Count)).SpecialCells(xlCellTypeVisible)(1).Row
    If GetFilteredRangeTopRow = LastFilterRow + 1 Then GetFilteredRangeTopRow = 0
  End With
NoFilterOnSheet:
End Function
Genius !! Thanks !!

I know its old , but thank you very much.

Dear op or anyone reading this after so many years,
just reference the function at the end after processing your macro all as usual , so you process that 1st visable row that was aluding you .

Like this, after your main sub or loops: ... Range("A" & GetFilteredRangeTopRow).Select ... etc.

There are always edge cases, and this line of thinking to handle was genius. Youve helped Rick Rothstein & you always help, no end. !!!
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,598
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top