VBA Help

D03274256

Board Regular
Joined
Nov 14, 2011
Messages
70
In vba how would I cycle through all the cells in column A (starting with A2) that have data, and store the data?
Meaning, let me take the value from A2....run code, then come back and take the value from A3, run code, then value from A4...all the way until column A is null?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Something like

Code:
Sub Test()
Dim lr As Long, c As Range
lr = Cells(Rows.Count,"A").End(xlup).Row
For Each c In Range("A2:A" & lr)
    'do some stuff using c as the range
    c.Interior.Color = 3
Next c
End Sub
 
Upvote 0
try below
Code:
Sub Test()
Range("A2").Select
Do Until ActiveCell.Value = ""
'do what u want some stuff like below all cell will highlight
ActiveCell.Interior.ColorIndex = 6
ActiveCell.Offset(1, 0).Select
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,397
Messages
6,119,273
Members
448,883
Latest member
fyfe54

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top