VBA For Loop – Loop Through a Range of Cells



If you want to test a condition for each cell in a range using VBA, the best way is to loop through the range, testing each cell. Here are two code examples to demostrate how to loop through a range. You can replace the range value for whatever range you need to loop through.

Loop Through Entire Column

The first example loops through the entire column A range. The if statement tests the condition if the cell contains the text “FindMe” and shows a message box with the location of the text if found.

Loop Through Entire Row

The next example loops through row 1 considering the entire row a range.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!


<<Return to VBA Examples

Did you find this VBA tutorial useful? Then share it with your friends and colleagues:

Leave A Comment