+ Reply to Thread
Results 1 to 7 of 7

vba to change cell color based on date

  1. #1
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    vba to change cell color based on date

    Hi guys what i need is a bit of vba code that can change a range of cells backcolor if an adjacent cell contains a date.

    i.e cells A1 to A55 and B1 to B55, if say B1 contains a date A1 turns GREEN, and if B15 contains a date A15 turns GREEN, but for the code to check all cells in B and change the A adjacent cell in A if the B column cell contains a date, i have tried conditional formatting, but would prefer using vba.

    hope this is clear

    scouse13

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: vba to change cell color based on date

    Hi scouse13 ... Something like this ?

    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: vba to change cell color based on date

    what about this?

    Please Login or Register  to view this content.
    https://docs.microsoft.com/en-us/off...range.interior

  4. #4
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Re: vba to change cell color based on date

    sorry mate got confused, i am copying data to a sheet, so the dates will be in the copied cells, ie sheet2(sheet were data is copied to) range A1-A50, the code needs to check these cells and change green if they contain a date, sorry for the confusion

  5. #5
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: vba to change cell color based on date

    Ok, how about now ?
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-27-2014
    Location
    bristol, england
    MS-Off Ver
    excel 2007
    Posts
    264

    Re: vba to change cell color based on date

    thanks for that, it works fine and i figured out how to change the font color as well, 1 more question if i may, i need to the code to check different columns, but not in order it needs to check column B and F nd i AND P, IS THIS POSSIBLE, CHANGING FONT COLOR AS WELL

  7. #7
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: vba to change cell color based on date

    Hi scouse13,

    Try the below code ...
    Please Login or Register  to view this content.

+ 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. How to make a cell adaptively change color based on its date?
    By Thlian in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-11-2018, 05:11 PM
  2. Replies: 5
    Last Post: 12-07-2013, 02:21 PM
  3. Change cell color based on date
    By khaladzki in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2011, 12:02 AM
  4. change cell color based on last edited date
    By pubudu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2011, 02:11 AM
  5. Cell color change based on date
    By jlaskaris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-07-2011, 03:36 PM
  6. cell color change based on due date
    By MINAL ZUNKE in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-30-2005, 05:05 PM
  7. [SOLVED] Change cell color based on date
    By RRP333 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-02-2005, 02:06 AM

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