+ Reply to Thread
Results 1 to 10 of 10

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

  1. #1
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

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

    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.
    Last edited by aneshdas; 01-06-2014 at 02:14 AM.

  2. #2
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

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

    Friends, Kindly help. Please

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

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

    In which cell do you have the date value.

    The logic would be to check if tocay() is greater than say Range("a1") (assuming that a1 has a date value.


    Please Login or Register  to view this content.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  4. #4
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

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

    Sir,

    I put the date value in C1 and used excel formula =TODAY(). Also the problem is I am not manually entering any date. The date on that particular column will be automatically changed.

    Sir, also I got a logic, I am already using some other macros to hide some columns based on today date. More clearly, I already inserted 1 to 31st dates in column B to Z ( assume) and on those columns 1 to 31 date is pre entered in each columns 2 ROW. So on today,the column which is having today's date only will be displayed (using a macro with workbook Open process). So that how about setting range as B to Z and start with if B= hidden then clear contents. On next day it has to calculate B+1 column ie, C has to check whether hidden or not, if hidden the column contents has to be cleared. Can we do like that Sir?
    Last edited by aneshdas; 01-06-2014 at 05:12 AM.

  5. #5
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

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

    you can try this ,


    Please Login or Register  to view this content.
    alternatively you can use the column number instead of column name.


    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

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

    Sir, But it has to be calculated everyday from 1st to 31st. Also every day checking the column for hiding has to be increased +1.

    I am putting =TODAY() in AL2, So when workbook open Screen updation has to be stopped and if AL2 is < Today then Clear the contents in A7:A500. Is it possible? Screen updation = False can be worked for stopping from changing the date too for a while??? Please advice sir.

  7. #7
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

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

    It would be better if you could post a sample workbook , marking your requirement.

  8. #8
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

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

    Sir, I got it.
    I did like this, Thanks a lot for your Kind help Sir....

    Private Sub WorkSheet_Activate()
    Application.ScreenUpdating = False
    If Range("B2") < Date Then
    Range("A2:A50").ClearContents
    End If
    Range("B2") = Date
    Application.ScreenUpdating = True
    End Sub

  9. #9
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

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

    Great,

    You could solve this yourself, Please mark this thread as solved.

  10. #10
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

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

    Sir,
    I have posted one more thread in this forum. Kindly go through it and please help me to solve this. Anticipating your solution.


    http://www.excelforum.com/excel-prog...ml#post3534260

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] I need a macro to clear cells based on contents
    By emymeeky in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-28-2013, 08:54 AM
  2. Macro to Clear Contents of Cells when one cell = 0 %
    By BVT3030 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2013, 02:55 AM
  3. Replies: 6
    Last Post: 06-05-2013, 12:14 AM
  4. Replies: 18
    Last Post: 02-10-2013, 05:32 PM
  5. Clear contents of cells in a range, LEN=0
    By jenny_journalist in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-29-2009, 11:37 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1