Hi,
I am looking for a VBA code to put into a button on the Index page of a workbook that will move the cursor on all existing worksheets to B1. This doesn't need to move the cursor on the Index page as well only all the worksheets which may be hidden or visible.
Thank you for your time,
Josh
Excel VBA for bringing cursor to A1
-
- Administrator
- Posts: 78236
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Excel VBA for bringing cursor to A1
A1 or B1? I used A1 in the following, and I used Index as the name of the index sheet.
Code: Select all
Sub Button1_Click()
Dim w As Worksheet
Application.ScreenUpdating = False
For Each w In Worksheets
If w.Visible = xlSheetVisible And w.Name <> "Index" Then
w.Select
w.Range("A1").Select
End If
Next w
Worksheets("Index").Select
Application.ScreenUpdating = True
End Sub
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 94
- Joined: 16 Oct 2021, 16:22
Re: Excel VBA for bringing cursor to A1
It'll be for B1 just because a1 is hidden. I believe this works great. As per usual thank you Hans for the quick reply and amazing results.
-
- StarLounger
- Posts: 94
- Joined: 16 Oct 2021, 16:22
Re: Excel VBA for bringing cursor to A1
Hi Hans,
Actually I was wondering if there was a modification you could make where it also scrolls each of the worksheets up as well?
Actually I was wondering if there was a modification you could make where it also scrolls each of the worksheets up as well?
-
- Administrator
- Posts: 78236
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Excel VBA for bringing cursor to A1
Like this:
Code: Select all
Sub Button1_Click()
Dim w As Worksheet
Application.ScreenUpdating = False
For Each w In Worksheets
If w.Visible = xlSheetVisible And w.Name <> "Index" Then
Application.Goto w.Range("B1"), True
End If
Next w
Worksheets("Index").Select
Application.ScreenUpdating = True
End Sub
Best wishes,
Hans
Hans