+ Reply to Thread
Results 1 to 8 of 8

How to colour cells by Month.

  1. #1
    Registered User
    Join Date
    05-20-2013
    Location
    Kegworth, England
    MS-Off Ver
    Excel 2019
    Posts
    58

    How to colour cells by Month.

    Hi All,
    I have, what I think, is simple problem. But for the life of me I cannot work out the logic.

    I have a simple list of 24 birth dates in column A, A1 to A24, formatted as dd mmm yyyy.
    In Column B, I have the corresponding dates, formatted as just mm. Just giving the month number.
    I would like the dates cells in column A to alternate colours, say light green and darker green, based on each month.
    I used conditional formatting initially and it worked fine as long as there was a date in each month.
    However, if there there are, for example, no dates in April, then March and May are the same light colour.

    I've tried For-Next loops in VBA but cannot work it out successfully.
    If someone could point me in the right direction I would be very gratefull.

    Thanks
    Last edited by AndyRoo119; 03-31-2021 at 12:37 PM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: How to colour cells by Month.

    Have you tried two conditional formatting rules:

    =ISODD(ROW())

    and:

    =ISEVEN(ROW())
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-20-2013
    Location
    Kegworth, England
    MS-Off Ver
    Excel 2019
    Posts
    58

    Re: How to colour cells by Month.

    Hi ALIgw,

    I understand that, but, if there is a date of 10 January 1978 (M01) - with a light background
    No dates in February (M02) - dark background,
    Then a date of 8 March 1998 (M03) - light background,
    both adjacent cells, the January and March date will be the same light colour.

    So that people can readily see the difference between January and March, I want March to now be the dark background so as to contrast the colour January then,
    If in the future, a date is added in February, that date cell will become the dark colour and March will become the light colour, and so on.

    Perhaps I should have said that the dates in column A are dynamic. Rows are added or deleted as required.
    Sorry if i didn't make it clear.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: How to colour cells by Month.

    There are instructions at the top of the page explaining how to attach your sample workbook.

  5. #5
    Registered User
    Join Date
    05-20-2013
    Location
    Kegworth, England
    MS-Off Ver
    Excel 2019
    Posts
    58

    Re: How to colour cells by Month.

    Hi again,
    Have attached the sample.
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: How to colour cells by Month.

    You didn't mock up how you want it to look.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to colour cells by Month.

    Changed Column B to =MONTH(A1) and formatted to custom 00

    Selecting A1:B24: Conditional Formatting> New Rule > Using Formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Next rule
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Is that what you are looking for?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  8. #8
    Registered User
    Join Date
    05-20-2013
    Location
    Kegworth, England
    MS-Off Ver
    Excel 2019
    Posts
    58

    Re: How to colour cells by Month.

    Thanks ChemistB
    Just what I was looking for.
    (I would never have worked out that conditional formatting)

    Thanks once again.

+ 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. Colour coding date cells when one month due
    By Lisa-Marie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-16-2019, 05:26 AM
  2. [SOLVED] Search cells based on student name, cell background colour and return a tally for colour
    By drof_06 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-26-2016, 04:31 AM
  3. Replies: 3
    Last Post: 02-13-2014, 06:31 AM
  4. Change colour of cells based on another cell's colour (Not value)
    By LTrain89 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-25-2013, 08:44 PM
  5. [SOLVED] How to make cells change colour each month
    By christophconnor in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 06-12-2013, 11:43 AM
  6. Macro that clears contents of all cells of certain colour (colour 35) in all sheets
    By Hanskubansku in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-25-2012, 07:33 AM
  7. Changing a cell's colour basing on other cells' colour
    By rhua5436 in forum Excel General
    Replies: 11
    Last Post: 09-23-2010, 05:49 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