简体   繁体   中英

Conditional formatting based on date in another cell

I have text in cell A1 that I want to apply conditional formatting to based on the dates in cells A2:A5. That is if a date in A2:A5 is older than today I want A1 to be filled in red. If the date in A2:A5 is less than 30 days from today I want A1 to be orange. I have tried various formulas and just cant seem to get it to work. Appreciate any help. Thanks

You need to use conditional formatting (button in the home ribbon). Choose new rule and click 'Use a formula'. Enter the formula you want and click format and select the fill colour you want it to be. Click OK. You can do this multiple times with different colours and formulas.

So something like this would make A1 change if A2 was within 30 days:

=$A$2<($A$1-30)=TRUE

But what colour would A1 be if the dates in cells A2:A5 are a variety of dates? Eg. some are less than 30 days some more? The technique above is easy when comparing A1 to one cell. I am not sure you have thought about this or you just have not explained yourself properly.

EDIT:

If A1 is not a static date and you want formatting based on the current timeframe (eg B1 falls within 30 days) then use the Date Occurring feature. Examples of how you can use if below. So you are going to need 12 of these to cover B1:G1 with 30 days for orange and one day for red.

发生日期 X内的日期

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM