• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to Clear contents in a range of cells when Date change.

Anesh

New Member
Friends,

I have a work sheet and on that I have datas in A7:A50. I need to clear the contents in that cell when the date change. More clearly. I am using that column for Remarks and, if I wrote something on that column being used only for today. next day morning I want that columns to be cleared. Kindly provide me a Macro for the same. So I want the datas in that particular cells has to be cleared after 24 hours. Kindly help me.
 
Last edited by a moderator:
Anesh
Firstly, Welcome to the Chandoo.org Forums

Add the following code to the Worksheet Module in VBA of the worksheet you are interested in
It will be executed as soon as you access that worksheet

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Date <> [A1] Then 'Change address to where yesterday's date is stored 
  Range("A7:A50").ClearContents
  Range("A7:A50").ClearComments
End If
[A1]=Date 'This resets the date for today
End Sub

Change the two references to A1 to a cell that suits you
 
Back
Top