Opening worksheets in cell A1

scouse

Board Regular
Joined
Jan 16, 2004
Messages
207
I have the following code in My Workbook. It is supposed to do two things:

1) Ensure the User always goes to the opening worksheet (Top) when they open up the workbook

2) Ensure the user always goes to cell A1 of each worksheet when they open each worksheet


Private Sub Workbook_Open()
Sheets("Top").Select
Dim X As Integer

Application.ScreenUpdating = False
For X = 1 To Sheets.Count
If Sheets(X).Visible = True Then
Sheets(X).Select
Range("A1").Select
End If
Next X
Sheets(1).Select
Application.ScreenUpdating = True
End Sub


It does number 1 but doesnt do number two - can anyone help with the code

regards

Scouse
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
on each worksheet paste this code!

Code:
Private Sub Worksheet_Activate()
Range("a1").Select
End Sub
 

Mudface

MrExcel MVP
Joined
Feb 18, 2002
Messages
3,339
As an alternative to putting it into each worksheet module, you can also put code in the ThisWorkbook module to apply to all sheets-

Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)

On Error Resume Next ' In case it's a chart sheet
Sh.Range("A1").Select

End Sub
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,563
Messages
5,765,123
Members
425,262
Latest member
sabry

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
Top