transcript

excelisfun - Excel Magic Trick 1173: Conditional Format Dates When they are 90 Days of Set Expiration Date

Thumbnail of the video “excelisfun - Excel Magic Trick 1173: Conditional Format Dates When they are 90 Days of Set Expiration Date”
Download Markdown
Community upload. AI output has not been independently verified.

Welcome to Excel Magic Trick number 1,173. If you want to download this workbook and follow along, click on the link below the video. In this video, we have some dates, and we need to use conditional formatting to color all the ones that are greater than 90 days away from the expiration date green, all the ones that are 90 all the way to one day need to be yellow, and the ones past this date or equal to it have to be red.

Now, when we're doing conditional formatting and there's not a built-in feature to do this, we can use formulas. I'm going to build the formula off to the side and copy it down and see if we can get our formula to work. Here's the deal: if we're asking questions of a cell, "Do you meet a condition?" so we can apply some formatting, it's all down to true or false. If it's true, it gets the formatting; if it's false, it doesn't. So we're going to actually use a logical formula, a true/false formula.

First, we've got to figure out what the difference is between all of these dates and the expiration date. The way we do that is we do a date formula. Equal sign starts all formulas. Now, dates, this is further through history than most of these, so I'm going to take the bigger date. That's a relative cell reference. If I copied that down, that blue box would move as I'm copying, so I'm going to lock it by hitting the F4 key. F4 puts the dollar signs in, which means it's locked on F4. Then I'm going to subtract this date. That's a relative cell reference; that orange one will move down as I copy the formula down. Control+Enter to put the formula in the cell and keep the cell selected. Now I'm going to point to that fill handle here. Here's my selection cursor, and when I see my selection cursor turn to that crosshair, or angry rabbit, I'm going to click and drag. Now I can see I've got my days right here. 33, 2015, that's exactly 90 days away. That's when it should start turning yellow, and look here, that one should be red, and so should that one.

Now, what do we do? We need a true or false, not just a number. So I'm going to come up to the top and hit F2, and now I'm going to use a comparative operator: is the number less than or equal to 90? I'm going to have to lock that with the F4 key. So all of these numbers up here will get falses. Here, this will get a true because it's equal. That one right there, 76, will get a true because it's less than. Control+Enter. Hey, there's our logical value. Instead of dragging it all the way down, I'm just going to point to my fill handle with my angry rabbit and double-click and send it down. Now that's the pattern of trues and falses for the yellow.

But guess what? We have one, two, three conditions: green, yellow, and red. That means we actually are going to have an initial color of green, and then a formula to apply yellow, and a second formula to apply red. Now let's put this in edit mode, and I'm going to cheat and copy this. Control+C, edit mode, Escape, and Control+V, F2 to put it back in edit mode. This is not going to be less than or equal to 90; it's got to be less than or equal to zero, because right there that's zero, and that's a bunch of minus numbers, right? So it's going to be less than or equal to zero. Control+Enter, double-click, and send it down. Now we get our last two trues for red. All the other ones will be false.

Now, if we're doing three conditions, we highlight the cells and apply the first condition, which will be the default condition. I'm going to use the Home ribbon and my fill bucket, and maybe green. That's kind of got a dark value, so I'm going to apply a light-colored font. Maybe you don't like that, maybe you do. You can do whichever formatting you want. Now I'm going to come to this cell and copy this formula. These are just for us to build our formula and see the patterns of trues and falses; we'll delete them in just a second. Let's copy this, Control+C, edit mode, Escape. The trick to conditional formatting is that you highlight all the cells, with the active cell at the very top. When I open up this dialog box and paste the formula into the dialog box, it'll be as if I pasted the formula into the cell, and it will automatically copy down. Now I go up to Home, Styles, Conditional Formatting, New Rule, or I can use the keyboard, Alt, H, L, N.

This dialog box is asking us a bunch of questions. We want the one at the very bottom: "Use a formula to determine which cells to format." I'm going to arrow, arrow, arrow. I can click in this text box, "Format values where this formula is true," or I can hit Tab to get to it, Control+V to paste. Now I can go to my formatting. This one needs to be yellow. I'm going to go to Fill, yellow is sufficiently bright, we don't need to change the font color. Okay, okay. Oh, we can see we actually are going to have to fix the font color, because the default is white and we don't want that. But let's not waste any clicks. Let's copy this, because we're going to have to paste this up there anyway. Control+C, Escape, highlight the same range, and Home, Styles, Conditional Formatting, Manage Rules, or Alt, O, D. Now I want to edit this because we need to change the formatting. I'm going to double-click it or click on it and say Edit Rule. Double-click, and down here under Format, I need to change the font back to black. Click OK, click OK. Now I can click New Rule, Formula, or arrow, arrow, arrow, Tab into the text box, Control+V. We're going to go to Format, Fill, red, and white font will look good with red. Click OK, click OK. Whoa, there's two of them now. This one will take precedence because it's on top, so that will work. Click OK. Absolutely beautiful, and this is dynamic. If I change this to 1 SL, 1 SL, whatever, somewhere before the 90-day hurdle, it changes. Control+Z. If I were to change this to 6/2 and press Enter, it changes. It's all dynamic. Control+Z. Now, I would then highlight these and hit the Delete key, but I'm going to Control+Z, which is undo, to just leave them there so when you download this you can check it out. All right, we'll see you next trick.