Make cursor auto return to cell A1

L

Legacy 32120

Guest
Hello,

Is there a way of automating the cursor to default to cell A1 (in all sheets) when closing the workbook?

With thanks,

Max Kramer :)
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try this in the ThisWorkbook module

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
    Application.Goto reference:=ws.Range("A1"), scroll:=True
Next ws
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks muchly VoG, that's great!

Is there a way of doing the same thing without a macro?

I'm planning to share the workbook and I'm told macros should be avoided where possible.

Cheers,

Max Kramer :)
 
Upvote 0
I don't know how to do that without code.

I believe that that code will run correctly in a shared workbook but I believe that shared workbooks should be avoided if at all possible :)
 
Upvote 0
I guess it will be up to my readers to choose whether or not to enable the code. It is definitely worth having this feature!

Thanks muchly again.... :)
 
Upvote 0
Strange?! The code fails after the following operations:
1) run ASAP Utilities Find/Replace, and/or
2) run the following macro.

Public Sub SpellCheckTextboxes()
Cells.CheckSpelling SpellLang:=1033
End Sub

(Reloading Excel or rebooting the system has no effect.)

With hope,

Max :)

P.S. BTW can resetting the cursor be done when loading the workbook?
 
Upvote 0
Oooops! Sorry... I'd put the code in a new Module. Moved code to ThisWorksheet. All sheets reset to A1. But when both saving & reloading workbook it defaults to last Sheet.
How to specify default to Sheet1 please?

Thanks...
 
Upvote 0
Try

Rich (BB code):
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
    Application.Goto reference:=ws.Range("A1"), scroll:=True
Next ws
Sheet1.Select
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,816
Members
449,095
Latest member
m_smith_solihull

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