Excel Knows If You Won the Lottery

Apparently you have to buy a ticket if you want to win the lottery, so I'm out of luck. However, if you're in an office lottery pool, or buy your own tickets for the lottery, Excel can let you know if you have a winning ticket. It just takes a bit of conditional formatting, and the COUNTIF function.

CondFormatLottery00

You could use this technique to highlight other things too, based on a list of items to check. For example, you could create a list of bad accounts or obsolete products, and highlight those on an Excel worksheet with product order requests.

Highlight Lottery Numbers

In this example the ticket numbers are in cells B2:G4, and the winning numbers drawn for the current lottery are entered in cells B6:G6.

Follow these steps to highlight the winning numbers in the list of tickets:

  1. Select the cells were the conditional formatting will be applied, B2:G4
  2. On the Excel Ribbon's Home tab, click Conditional Formatting
  3. Click New Rule
  4. In the New Formatting Rule window, click Use a Formula to determine which cells to format
  5. For the formula, use the COUNTIF function, and refer to the active cell:
    =COUNTIF($B$6:$G$6,B2)
  6. Click the Format button.
  7. Select the formatting options that you want (blue fill colour, in this example), then click OK.
  8. Click OK

CondFormatLottery01

The cells with winning numbers are highlighted in blue, and other cells have no fill colour.

There are more examples of Excel conditional formatting on the Contextures website.

Watch the Video

To see the steps for highlighting the winning lottery numbers with Excel conditional formatting, please watch this short Excel tutorial video.

Excel Tweet of the Day

Is resistance futile? Will this tweeter succumb to the temptation to tidy up? Would you?

  • another excel VBA morning. Delete works now:) ..... But can I resist the temptation to tidy up all the code now even though it works fine?

For more entertaining and enlightening Excel tweets, culled from the thousands posted every day, see the Excel Theatre Blog.

___________

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>