PDA

View Full Version : VBA loop help



Seanconn520
05-21-2013, 11:39 AM
So I'll try to keep this brief. As part of a macro I have a part that makes sure all the values in certain columns are numbers. Each of these checks only need to be done while column A is <> "".

I have one way of doing it which is very tedious (because there are so many columns to check) which is

For each cl in range("c2:c600")
If cl.offset(o, -2).value <> "" then
If cl.numberformat = false then
Msgbox:=("cell isn't number")
End if
End if
Next cl


This is done for each column because I don't know another way to do it but what I would like to do is something like

For each cl in range("c2:BB600")
If cl.offset(0, 2).value <> "" then

but I want this offset to always refer to column A... Any thoughts?

patel
05-21-2013, 11:50 AM
dim cl as range
For each cl in range("c2:BB600")
If range("A" & cl.row) <> "" then
If cl.numberformat = false then Msgbox:=("cell isn't number")
End if
Next