Before_Close VBA function

akparasite

Board Regular
Joined
Jul 15, 2002
Messages
55
Does anyone know of a slick way to make a worksheet reset the active cell to a particular worksheet/cell reference upon closing?

Why? I have some macros that require that the first sheet in the workbook is the active cell, and I don't want other users to mess up the file by saving it without resetting to the first worksheet.

Your help is greatly appreciated!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try this

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error GoTo NOMENU
Range("A1").select
Exit Sub
NOMENU:
On Error GoTo 0
End Sub
 
Upvote 0
It only has to APPEAR to happen on close. Instead set this to happen on OPEN like this:

In the WorkBook Module place this snippit

Private Sub Workbook_Open()
Sheets("Sheet1").Select
Range("A1").Select
End Sub

Done like this it does not matter if they save changes, each time the work book opens it goes to sheet 1 cell A1

If you switch between workbooks put this in the WorkBook Activate event as well Like this:

Private Sub Workbook_Activate()
Sheets("Sheet1").Select
Range("A1").Select
End Sub


Yours in EXCELent Frustration

KniteMare
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

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