BeforeSave event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to build a macro that will automatically clear the contents of a
certain cell just before the workbook is saved. I tried entering is as
follows but it did not work:
Sub Workbook_BeforeSave()
Sheets("Instructions").Select
Range("E5").Select
Selection.ClearContents
End Sub
Thanks
 
where did you park this sub. it should be parked after
clicking<thisworkbook>
click the excel icon before the menu <file> and click view code. in the
resuting <thisworkbook(codee)> sheet click on the left hand side arrow and
click <workbook> there you park thesub.
if you have already done this then there is some other problem.

by the by has the workbook already been saved once.
 
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Sheets("Instructions").Select
Range("E5").Select
Selection.ClearContents

End Sub
 
sorry ;i missed one point the sub heading is

Private Sub Workbook_BeforeClose(Cancel As Boolean)

End Sub
after clicking workbook goto right side click <before closse> then write
your code statements.

mine is excel 2000
 
In the ThisWorkbook module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Sheets("Instructions").Range("E5").ClearContents
End Sub
 

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

Similar Threads


Back
Top