Excel VBA IF THEN Statement (and a useful tip)

... also learn how to loop through cells

Excel VBA IF THEN StatementExcel VBA IF THEN Statement is one of the most useful statements in VBA.

In this tutorial, you’ll quickly learn how to work with the IF, THEN, ELSE, ELSEIF as well as the AND statements.

This way you can write Excel macros that are dependent on multiple conditions.

We also take a look at looping through a range of cells using Excel table referencing. I use the FOR EACH VBA construct for looping. During the loop, we check the value in the cell and change the background color of the cell depending on the value.

In addition to learning the IF THEN statements and how to loop through cells, you also learn how to quickly get the color code of a specific cell so you can refer to it in your Excel macro.

I’ll show you a trick with the immediate window and how you can test, and query code in there.

Watch the steps in this video:

Feel free to Download the Workbook HERE.

Free Excel Download

Unlock Excel VBA & Macros Course is here.

Save time. Achieve more.

Over 50 Excel macro examples for download & useful VBA codes you can use for your work.

Redeem your coupon for 75% off below.

Get 75% off the course
Free Ebook


  1. YasserKhalil August 30, 2018 at 7:14 pm - Reply

    Awesome and great tutorial

    • Leila Gharani September 3, 2018 at 4:03 pm - Reply

      Thank you!

Leave A Comment

Share This