ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear cells (https://www.excelbanter.com/excel-programming/363158-clear-cells.html)

One-Leg

Clear cells
 
Hello,

I have a file that I would need certain cells to be cleared out when the
file is opened for the first time during the day!!!

What the file does is basically for my employees asking to leave earlier,
they add their name to the file, save it and close it. I want to have a
macro that will run everytime the file is opened and if you are the first
person opening it today (so basically if the last time it was saved was for
yesterday's date), I would like to have certain fields to be cleared...

If any one know of a way to do this, it would be great...

Thanks!!!

Chip Pearson

Clear cells
 
Just use something like

Range("A1,C1,E1").Value = ""

Change the cells to the ones you want to clear.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"One-Leg" wrote in message
...
Hello,

I have a file that I would need certain cells to be cleared out
when the
file is opened for the first time during the day!!!

What the file does is basically for my employees asking to
leave earlier,
they add their name to the file, save it and close it. I want
to have a
macro that will run everytime the file is opened and if you are
the first
person opening it today (so basically if the last time it was
saved was for
yesterday's date), I would like to have certain fields to be
cleared...

If any one know of a way to do this, it would be great...

Thanks!!!




One-Leg

Clear cells
 
That I know!!!

But what I don't know is how can it be done as soon as the file is opened
but only when the file is opened for the first time during the day!!!

"Chip Pearson" wrote:

Just use something like

Range("A1,C1,E1").Value = ""

Change the cells to the ones you want to clear.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"One-Leg" wrote in message
...
Hello,

I have a file that I would need certain cells to be cleared out
when the
file is opened for the first time during the day!!!

What the file does is basically for my employees asking to
leave earlier,
they add their name to the file, save it and close it. I want
to have a
macro that will run everytime the file is opened and if you are
the first
person opening it today (so basically if the last time it was
saved was for
yesterday's date), I would like to have certain fields to be
cleared...

If any one know of a way to do this, it would be great...

Thanks!!!





Bearacade[_5_]

Clear cells
 

Try this.. put this in ThisWorkbook.

I am assuming that your data is A1:A10 and that you can use B10 as a
"spot" for date. You can adjust accordingly.



Private Sub Workbook_Open()


If Range("B10").Value < Format(Now(), "MMM DD YY") Then

Range("A1:A10").Value = ""

End If

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

Range("B10").Value = Format(Now(), "MMM DD YY")

End Sub


--
Bearacade
------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=547990



All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com