View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Macro to select all sheets

This workbook event macro assumes the reference date in is cell A1 in the
first sheet. If you open the workbook and the reference date is in the
future, nothing happens. If you open the workbook and the reference date is
in the past, then all the cell in the sheets are cleared and the workbook is
saved:

Private Sub Workbook_Open()
Sheets(1).Activate
If Date Range("A1").Value Then
For Each sh In Sheets
sh.Cells.Clear
Next
ActiveWorkbook.Save
End If
End Sub


WARNING: mis-using this macro can be as bad as crossing the streams.
--
Gary''s Student - gsnu200775


"belvy123" wrote:

Hi All

I am needing help with code for a macro
I want to have this macro run on every opening of file and compare to the
current date. If the date is matched or past the current date I want to
select all sheets in the work book and then clear all data in the sheets. And
then save the file also.
Can anyone help with this

Thanks


--
crunchin numbers