sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 568
- Office Version
- 365
- Platform
- Windows
Good morning,
I'm trying to get my code below right to allow me to scroll over to a table column on my worksheet. I can easily enter the column number (13) and it will do just that, but trying to keep this code dynamic so that I can insert additional columns down the road and not have to worry about re-writing the code for column number references. Not that I have the first two rows and first 5 columns set as frozen panes. Any help would be greatly appreciated.
Thanks, SS
I'm trying to get my code below right to allow me to scroll over to a table column on my worksheet. I can easily enter the column number (13) and it will do just that, but trying to keep this code dynamic so that I can insert additional columns down the road and not have to worry about re-writing the code for column number references. Not that I have the first two rows and first 5 columns set as frozen panes. Any help would be greatly appreciated.
Thanks, SS
VBA Code:
Sub Scroll_to_PMT_COL()
'
' Scroll to Payment Column Macro
'
Dim wBook As Workbook
Dim wSheet As Worksheet
Dim tb As ListObject
Set wBook = ThisWorkbook
Set wSheet = wBook.Sheets("Jobs")
Set tb = wSheet.ListObjects("G2JobList")
Worksheets("Jobs").Activate
ActiveWindow.ScrollColumn = tb.ListColumns("Down" & Chr(10) & "Payment").Select
End Sub