+ Reply to Thread
Results 1 to 7 of 7

VBA to format cells based on difference from todays date

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Belfast
    MS-Off Ver
    Excel 2010
    Posts
    3

    VBA to format cells based on difference from todays date

    Hi can anyone help I have been searching the forums for 2 days now and any replies I find are not exactly what I am looking for.
    I want to use VBA as the conditionally formatting in excel can only handle it being applied to a limited number of cells and I have hundreds in the one sheet and it keeps falling over...
    So I thought I would try VBA.
    I want to choose from cells within a range of b7:bd100 and apply particular formatting.
    That if the value in each cell is within these range of conditions a different colour will be filled in .
    IF date value in cell is between Todays date +14days and todays date +21days = colour of cell orange
    If date value in cell is between Todays date and todays date +14days = colour of Cell Red
    If date value in cell is <= todays date = colour of cell Red
    Column B (is a date value) and column d (is a true or false value)
    When true or false or n/a is applied to this field it will also color the cell in column b the same colour

    Can this be done.

    Thanks for any assistance that you can give.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to format cells based on difference from todays date

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: VBA to format cells based on difference from todays date

    Try the macro. The number of criteria options is in B1, shades and range limits can also be changed.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to format cells based on difference from todays date

    Perhaps you wanted Event Code?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-06-2012
    Location
    Belfast
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA to format cells based on difference from todays date

    HI I pasted this code into my worksheet and it does not seem to work. Can you help but I think I may have not written my query properly.
    I have cell B2 which has a date in it and corresponding cell C2 which has a text in it yes/no/N/A
    I want cell b2 to be formatted with a colour if the date is different that todays date by various parameters. Then in Cell C2 if it has one of the three text options it will be coloured red/Green or white and this will then recolour cell b2 to the same colour.
    does this make sense?

  6. #6
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: VBA to format cells based on difference from todays date

    could you send the sample data? It is unclear if all are dates of are sets of dates and true/false columns, or b=date, c=? d=true/false and the rest are dates..

  7. #7
    Registered User
    Join Date
    12-06-2012
    Location
    Belfast
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA to format cells based on difference from todays date

    Thanks for your reply.... please see attached a screen dump of a sample of the file.. I hope that this makes sense.. I have put comments in against each field...

    I hope that this makes it clearer what I am trying to do... I have created conditional formats for both cells and they work great it is just that I have too many rows and columns in my sheet and excel falls over.....


    Thanks for all of your assistance
    Attached Images Attached Images

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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