Thread: Save Macro
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Save Macro

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim wrksht As Worksheet
For Each wrksht In ActiveWorkbook.Worksheets
wrksht.Range("A1").Select
Next wrksht
Worksheets(1).Select
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sprinks" wrote in message
...
I'd like a macro that, prior to saving the current workbook, would

position
the cursor in cell A1, and make the first sheet the active one. The
following code does not work. Can anyone help?

Public Sub SaveWorksheet()
Dim wrksht As Worksheet
For Each wrksht In ActiveWorkbook.Worksheets
Range("A1").Select
Next wrksht
Worksheets(1).Select
ActiveWorkbook.Save
End Sub

Sprinks