+ Reply to Thread
Results 1 to 14 of 14

conditional formatting cells by date

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    10

    conditional formatting cells by date

    Hi

    I have a column with dates in the following format. 01-01-13 etc... In a sheet called January.

    I would like to accomplish in this sheet is to color code any cell that is not from January 2013

    =IF(AND(MONTH(A1)=1;YEAR(A1)=2013);"TRUE";"FALSE") //note I have to use ; and not , separator

    I think I am looking for something like the above statment though not quite.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: conditional formatting cells by date

    Something like this?

    =IF(AND(MONTH(A1)<>1;YEAR(A1)<>2013)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: conditional formatting cells by date

    ..And of course as my friend Vlady mentioned(Thanks), no need of IF in Cf.

    =AND(MONTH(A1)<>1;YEAR(A1)<>2013)

  4. #4
    Registered User
    Join Date
    01-30-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: conditional formatting cells by date

    For some reason I can't get it to work as expected (or so i think).

    If I test it I get the following...

    =IF(AND(MONTH(A1)<>1;YEAR(A1)<>2013);"TRUE";"FALSE")


    01-01-2013
    15-01-2013
    02-02-2013
    15-02-2013
    11-11-2011
    12-12-2012

    FALSE
    FALSE
    FALSE
    FALSE
    TRUE
    TRUE

    02-02-2013 and 15-02-13 should both be TRUE...right?

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: conditional formatting cells by date

    Ok. YES you are correct. We need OR. Not AND...

    =OR(MONTH(A1)<>1;YEAR(A1)<>2013)

  6. #6
    Registered User
    Join Date
    01-30-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: conditional formatting cells by date

    YES that sure did it.

    I do have a couple more questions though.

    If I only want to color code dates in the column and nothing else how would I go about doing that? (or just ignore empty cells would be fine too)

    If I wanted to create a sheet that stored the month and year values how would I go about doing that? Or maybe I would not as I don't seem to be able to make a reference to another sheet in a conditional statement?

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: conditional formatting cells by date

    1) =OR(AND(MONTH(A1)<>1;YEAR(A1)<>2013);A1>0)

    2) You CAN use a reference to another sheet using Named ranges. In this case i need more explanations and better will be to have a sample workbook.

  8. #8
    Registered User
    Join Date
    01-30-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: conditional formatting cells by date

    =OR(AND(MONTH(A1)<>1;YEAR(A1)<>2013);A1>0)

    Though empty cells are now ignored the statement seems to return true to all dates no matter month or year.

    I have attached a sample workbook with to sheets, "dates" and "lookatdates". I was imagining the following...

    =OR(AND(MONTH(A1)<>lookatdates!b1;YEAR(A1)<>lookatdates!A1);A1>0)

    sample_workbook_dates.xlsx

  9. #9
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: conditional formatting cells by date

    Hi samson1000

    Try: =AND($A1<>"",OR(YEAR($A1)<>2013,MONTH($A1)<>1))
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  10. #10
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: conditional formatting cells by date

    2 CF

    See the example.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    01-30-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: conditional formatting cells by date

    Something strange is at works!

    If I add the following to a new sheet it works.

    =AND(C3<>"";OR(YEAR(C3)<>2013;MONTH(C3)<>1)) //as the formating begins in C3 in my sheet

    However if I ad it to an existing sheet it behaves somewhat randomly with the color coding. Even though the statement returns false on a date (I tested it) it will in some cases format (color code) the cell even when false is returned?

    ps
    @fotis1991, I see how the referencing is working, thanks.

  12. #12
    Registered User
    Join Date
    01-30-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: conditional formatting cells by date

    Sorry, it is working now.
    I just can't get it through my head that it somehow seems like I can't highlight a whole column if it starts in C3 that is.

    So awesome, thanks.

  13. #13
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: conditional formatting cells by date

    Have you tried clearing all formats, re apply them, some times this works. Or post a worksheet with dummy data.

  14. #14
    Registered User
    Join Date
    01-30-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: conditional formatting cells by date

    I'll try clearing another time but for now it's all good. Appreciate it though.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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