SELECT THE FIRST CELL IN ADVANCE FILTERed worksheet vba code
Hi CmK,
'--------------
Hi I need to know how to select the first cell or row in the advanced
filtered worksheet
Eg Ctrl + home
'--------------
I am not aware of a standard shortcut key but
perhaps you could assign something like the
following code to your own shortcut keys:
'=============
Public Sub Tester()
Dim destSH As Worksheet
Dim Rng As Range
Dim Rng2 As Range
Dim Rng3 As Range
Set Rng = Range(ActiveSheet.Name _
& "!_FilterDatabase")
If Rng Is Nothing Then
Exit Sub
End If
Set destSH = ThisWorkbook.Sheets("Sheet2") '<<=== CHANGE
With destSH
On Error Resume Next
Set Rng2 = .Range(.Name & "!Extract")
On Error GoTo 0
End With
If Not Rng2 Is Nothing Then
Application.Goto Rng2.Cells(2, 1)
Else
With Rng
Set Rng = .Offset(1).Resize(.Rows.Count - 1)
End With
On Error Resume Next
Set Rng3 = Rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not Rng3 Is Nothing Then
Rng3.Cells(1).Select
Else
Rng.Cells(1).Offset(-1).Select
End If
End If
End Sub
'<<=============
---
Regards,
Norman
|