Workbook_Close Command

  • Thread starter Jan Nademlejnsky
  • Start date
J

Jan Nademlejnsky

I am looking for a code which would restore the spread sheet to "Clean
State" before saving (when it is being saved):

Something like the following which would be automatically trigged when sheet
is saved:

Sub Before_Save ()
OnSave
ActiveSheet.AutoFilterMode = False
Range("A3").Select
end sub

Thanks for your help

Jan
 
D

Dave Peterson

Maybe you could use the workbook_beforesave event:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
With Worksheets("Sheet1")
.AutoFilterMode = False
Application.Goto reference:=.Range("A1"), scroll:=True
.Range("a3").Select
End With
End Sub


Right click on the excel icon to the left of File on the worksheet menubar and
select view code. Paste that in.

Save you workbook (adjust the name "sheet1" to what you need).
 
J

Jan Nademlejnsky

Hi Dave,

This is exactly what I was looking for. You made my day!

Thanks

Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top