Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default macro that works one time every day

Hi to everyone,
Is there any macro which delete the data in specific cells one time every
day when I opened the excel worksheet.
For example: when I open one worksheet for the first time in 20-9-2008, the
macro will delete the data from cells a5, a6, b7 and b9. If I open the same
worksheet another time in the same day, the macro mustnt be worked.
Thanks in advance.
Spiros

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default macro that works one time every day

Hi

Try this event in the Thisworkbook module
I use cell G1 to add a date, you can change that location

See this page if you are new to macros
http://www.rondebruin.nl/code.htm

Private Sub Workbook_Open()
With Sheets("Sheet1")
If .Range("G1").Value = Date Then
'do nothing
Else
.Range("G1").Value = Date
.Range("A5,A6,B7,B9").ClearContents
End If
End With
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Spiros" wrote in message ...
Hi to everyone,
Is there any macro which delete the data in specific cells one time every
day when I opened the excel worksheet.
For example: when I open one worksheet for the first time in 20-9-2008, the
macro will delete the data from cells a5, a6, b7 and b9. If I open the same
worksheet another time in the same day, the macro mustnt be worked.
Thanks in advance.
Spiros


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default macro that works one time every day

Hi,

If your file is saved then you could write the date to a cell but if it
isn't then that method won't work. This uses a text file to record whether
the macro has been run

Private Sub Workbook_Open()
filenum = FreeFile
fname = "C:\timesrun.txt"
If Dir(fname) < "" Then
Open fname For Input As filenum
Input #filenum, mydate
Close #filenum
End If
Open "C:\timesrun.txt" For Output As filenum
Print #filenum, Format(Date, "ddmmyyyy")
Close #filenum
todaysdate = Format(Date, "ddmmyyyy")
If CStr(mydate) = todaysdate Then
MsgBox "This macro has been run today"
Exit Sub
Else
Sheets("Sheet1").range("A5,A6,B7,B9").ClearContent s
End If
End Sub

Mike

"Spiros" wrote:

Hi to everyone,
Is there any macro which delete the data in specific cells one time every
day when I opened the excel worksheet.
For example: when I open one worksheet for the first time in 20-9-2008, the
macro will delete the data from cells a5, a6, b7 and b9. If I open the same
worksheet another time in the same day, the macro mustnt be worked.
Thanks in advance.
Spiros

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro works Macro does not work Wanna Learn Excel Discussion (Misc queries) 4 March 24th 08 12:51 PM
Macro do works in excel... driller Excel Worksheet Functions 7 July 12th 07 02:56 PM
Time for M$ to fix incompatibility with Office & Works Steve Garry Excel Discussion (Misc queries) 0 April 20th 06 09:10 PM
how do I create a hyperlink that works more than one time mcgrath Excel Discussion (Misc queries) 0 February 13th 06 03:41 PM
macro works for some users and doesn't for others Pooja Excel Discussion (Misc queries) 2 October 27th 05 08:27 PM


All times are GMT +1. The time now is 02:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"