Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

(80% Discount Ends Soon!)

Loop Through Every Cell in a Column in Excel

This Excel macro allows you to easily loop through every cell in a column within a worksheet.  This will only loop through a column if there is data in the column.

The benefit of doing this is that it makes it very easy to check the contents of each cell in a column.  All you have to do is to reference the value of a cell using something like "Cells(i, 1).Value"  The "i" is a variable used in the For loop that will increment up by one every time.  And, the "1" is the number of the column being looped-through, in this case column A.  If you changed this to work on column B, this number would be "2" and column C "3" and so on.

If you want to change the below macro to work on another column, follow the instructions in the last paragraph and also change the letter "A" in this part of the code

   For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
   
to the letter of the column through which you want to run the loop.


Where to install the macro: Module


Loop Through Every Cell in a Column in Excel

Select All
Sub Loop_Through_Column()

For i = 1 To Range("A" & Rows.Count).End(xlUp).Row

    'put your code here
   
    'if you want to reference the value of each cell within the column/loop, do something like this:
    '
    '   Cells(i, 1).Value
    '
   
Next i

End Sub