ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet Data Filters (https://www.excelbanter.com/excel-programming/291387-worksheet-data-filters.html)

D.S.[_3_]

Worksheet Data Filters
 
I'm writing some code to set worksheet filters, and would like to have my
active cell in the first visible row after the filters have been set.
Sometimes the active cell is in a row that has been filtered out, therefore
it's not visible.

Any ideas how to code this so that the active cell would be in the first
visible row? or any visible row?

--
D.S.



Dave Peterson[_3_]

Worksheet Data Filters
 
Stolen from a previous post:

Option Explicit
Sub testme()

Dim myRngF As Range

Set myRngF = Nothing
On Error Resume Next
With ActiveSheet.AutoFilter.Range
Set myRngF = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.Cells.SpecialCells(xlCellTypeVisible)
End With
On Error GoTo 0

If myRngF Is Nothing Then
MsgBox "No cell to select"
Else
myRngF.Areas(1).Cells(1, 1).Select
End If

End Sub



"D.S." wrote:

I'm writing some code to set worksheet filters, and would like to have my
active cell in the first visible row after the filters have been set.
Sometimes the active cell is in a row that has been filtered out, therefore
it's not visible.

Any ideas how to code this so that the active cell would be in the first
visible row? or any visible row?

--
D.S.


--

Dave Peterson


D.S.[_3_]

Worksheet Data Filters
 
That seems to work, thanks a lot.

"Dave Peterson" wrote in message
...
Stolen from a previous post:

Option Explicit
Sub testme()

Dim myRngF As Range

Set myRngF = Nothing
On Error Resume Next
With ActiveSheet.AutoFilter.Range
Set myRngF = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.Cells.SpecialCells(xlCellTypeVisible)
End With
On Error GoTo 0

If myRngF Is Nothing Then
MsgBox "No cell to select"
Else
myRngF.Areas(1).Cells(1, 1).Select
End If

End Sub



"D.S." wrote:

I'm writing some code to set worksheet filters, and would like to have

my
active cell in the first visible row after the filters have been set.
Sometimes the active cell is in a row that has been filtered out,

therefore
it's not visible.

Any ideas how to code this so that the active cell would be in the first
visible row? or any visible row?

--
D.S.


--

Dave Peterson





All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com