Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Clear fields based on date 1

Status
Not open for further replies.

5656

Technical User
Jan 6, 2001
68
US
Hello...
How would I set up an Excel worksheet to clear designated fields automatically on a specific day of the week -- Sunday for example ?
Thanks !!
 
what exactly do you mean ?
The fields (cells) will simply have either numbers or dollar values that will be input by users once a week and saved on the server.
 
Hello, 5656.

Suppose the range of fields you want to clear is B2:B3 for instance, and you want to have it clear on Sunday when the workbook is opened but not on the other days, a possible solution is as follows.

[1] Create a macro named Auto_Open(). The name as such is a requirement.
[2] Edit the macro :

Sub Auto_Open()
If WeekDay(Now()) = 1 Then '1 for Sunday
Range("B2:B3").ClearContents
End If
End Sub

[3] Range ("B2:B3") and day-of-week (1 for Sunday, 2 for Monday etc) are parameters you have to adapt to your worksheet structures and timing requirement.
[4] The macro will be auto-executed once the workbook is open and does the job as described.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top