Navigate through all the worksheet and Press Ctrl + Home Using VBA
If you want to select the first cell after freeze pane on each worksheet and save it. So that when user opens the workbook he/she do not have to press CTRL+ Home in each worksheet to go to first cell.
Here is the code -
Sub goto_first_cell_in_each_worksheet()
Dim wk As Worksheet
For Each wk In ThisWorkbook.Worksheets
If wk.Visible = xlSheetVisible Then
wk.Select
If ActiveWindow.SplitRow = 0 And ActiveWindow.SplitColumn = 0 Then
Application.Goto Range("a1")
Else
Application.Goto Range(Cells(ActiveWindow.SplitRow + 1, ActiveWindow.SplitColumn + 1).Address)
End If
End If
Next
ActiveWorkbook.Save
End Sub
- Ashish Koul's blog
- Login or register to post comments
- 11640 reads
Time-saving macro
Until now I used to manually hit CTRL-Home on every sheet, very cumbersome process for worksheets with several tabs. The macro using your code does this in seconds. Thank you very much.