ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set curser to Same position on open (https://www.excelbanter.com/excel-programming/346480-set-curser-same-position-open.html)

Martin

Set curser to Same position on open
 
I have a workbook with 3 pages. How can I set the curser on each page to a
starting position of cell A1 when the workbook is opened? Preferably,
something to the number of sheets in the workbook as they may fluctuate.

Thank you,
--
Martin

Rowan Drummond[_3_]

Set curser to Same position on open
 
In the ThisWorkbook module add the following Workbook_Open event.

Private Sub Workbook_Open()

Dim sh As Worksheet
Dim thisSh As Worksheet

On Error GoTo Event_Exit

Set thisSh = ActiveSheet
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
sh.Activate
Application.Goto Range("A1"), True
Next sh
thisSh.Activate
Event_Exit:
Application.ScreenUpdating = True
End Sub

Hope this helps
Rowan

Martin wrote:
I have a workbook with 3 pages. How can I set the curser on each page to a
starting position of cell A1 when the workbook is opened? Preferably,
something to the number of sheets in the workbook as they may fluctuate.

Thank you,


barry

Set curser to Same position on open
 
hi Martin

1. Select the ThisWorkbook sheet in the VBA Editor.
2. Paste in the following code.

Private Sub Workbook_Open()

Dim wksSheet As Excel.Worksheet

For Each wksSheet In ThisWorkbook.Sheets
If wksSheet.Type = xlWorksheet Then
wksSheet.Activate
wksSheet.Range("A1").Activate
End If
Next

ThisWorkbook.Sheets(1).Activate

End Sub

Each time you open the workbook it will put the cursor for each sheet back
to A1. It doesn't matter how many sheets you have in the workbook.

HTH

Barry


"Martin" wrote:

I have a workbook with 3 pages. How can I set the curser on each page to a
starting position of cell A1 when the workbook is opened? Preferably,
something to the number of sheets in the workbook as they may fluctuate.

Thank you,
--
Martin



All times are GMT +1. The time now is 04:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com