![]() |
BeforeSave event
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. Carl Bowman wrote in message ... 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 |
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean) Sheets("Instructions").Select Range("E5").Select Selection.ClearContents End Sub "Carl Bowman" wrote in message ... 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 |
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 Carl Bowman wrote in message ... 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 |
In the ThisWorkbook module
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Sheets("Instructions").Range("E5").ClearContents End Sub -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ---------------------------------------------------------------------------- It's easier to beg forgiveness than ask permission :-) ---------------------------------------------------------------------------- "Carl Bowman" wrote in message ... 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 |
All times are GMT +1. The time now is 02:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com