+ Reply to Thread
Results 1 to 8 of 8

Excel 2007 : Changing row background color based on AM or PM

  1. #1
    Registered User
    Join Date
    06-21-2012
    Location
    Kirkville, NY
    MS-Off Ver
    Excel 2007
    Posts
    4

    Changing row background color based on AM or PM

    I have a worksheet with 7 columns and 48 rows. The data in column A is a date and time displayed as "05/01/12 08:01 AM" (for example). I'd like to be able to have the background color in each row determined by whether the data in column A is AM or PM. I can make the cells in column A do this using conditional formatting, but I can't figure out how to make the entire row do it.

    If someone can help, I will certainly appreciate it.

    Please and thank you.

  2. #2
    Valued Forum Contributor
    Join Date
    06-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    341

    Re: Changing row background color based on AM or PM

    You can paste formatting along the row by dragging the row/column A across the row, then select Formatting Only

    Alternatively, just add a check for all other cells in that given row to check vs $A$1 for 1st row, $A$2 for 2nd row etc

  3. #3
    Registered User
    Join Date
    06-21-2012
    Location
    Kirkville, NY
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Changing row background color based on AM or PM

    Thank you for your quick response. I tried your first suggestion, and either it's not working for me, or I'm doing it wrong. I should tell you that I'm somewhat of a novice.

    I don't understand your second suggestion. I'm sorry.

    Again, what I want is for all the cells in a row to look at the first cell, and if it contains "AM" as part of the entry in the cell, then color the background a certain color. If if information in the first cell contains "PM" then color the background a different color. So all the cells in a row will be color-coded based on whether the first cell in the row contains "AM" or "PM"

    Thanks again.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,643

    Re: Changing row background color based on AM or PM

    1. Select the entire block of cells you wish to format.

    2. Write the format rule as such:
    =$x >=TIMEVALUE("12:00")
    Where $x is the top left cell of the block (e.g. $A1)
    Attached Files Attached Files
    Ben Van Johnson

  5. #5
    Registered User
    Join Date
    06-21-2012
    Location
    Kirkville, NY
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Changing row background color based on AM or PM

    Thank you for responding, and especially, for including an example. But, when I use your technique, I don't get what you got in your example. Instead, all of the rows change color.

    I've attached some sample data to show you what I'm working with. I would like for AM rows to be red, and PM rows to be green.

    If you are willing to take another crack at trying to help me, I would really appreciate it.

    Thanks,
    John

    Copy of Blood Glucose Data.xlsx

  6. #6
    Valued Forum Contributor
    Join Date
    06-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    341

    Re: Changing row background color based on AM or PM

    Hi John,

    Use this:
    =TIMEVALUE($A5)>=0.5 (if PM, color)

    To color AM, you can then use
    =TIMEVALUE($A5)<0.5

    All via conditional formatting

    I've tested this versus your workbook and it worked

  7. #7
    Registered User
    Join Date
    06-21-2012
    Location
    Kirkville, NY
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Changing row background color based on AM or PM

    WOW!!! It does indeed work. Thank you very much. Thank you thank you thank you.

    Did I say Thank You?

    Thanks,
    John

  8. #8
    Valued Forum Contributor
    Join Date
    06-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    341

    Re: Changing row background color based on AM or PM

    No worries.

    Remember to mark the thread solved etc

+ 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