When entering sheet I want to goto A1 if it's not already in A1

ColinCoady

New Member
Joined
Mar 21, 2019
Messages
35
Cant't get this to work.
Looking for code to automatically go to cell A1 (actually range A1:K1 because it's a merged cell) when I click on one particular sheet tab at any time and every time.

Hope someone can help
This is what I have that works only when I debug it step by step.

Code:
Sub Move2A1()
If Sheets("Docs").Select = True Then
    Cells(1, 1).Select
    End If
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Place this macro in the code module for ThisWorkbook. Do the following: Hold down the ALT key and press the F11 key. This will open the Visual Basic Editor. In the left hand pane, double click on "ThisWorkbook". Copy/paste the macro into the empty window that opens up. Close the window to return to your sheet. Select the sheet.
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    If Sh.Name = "Docs" Then
        Sh.Range("A1").Select
    End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,761
Messages
6,132,573
Members
449,736
Latest member
anthx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top