If Statment - Active Cell Column Address

R

Richard

Need to use an if statement in a macro to control program flow.

If active cell is in column C then ………….

Else …..

End if

How do I do this???

Thanks in Advanced

Richard
 
D

Dave Peterson

Another way:

with activesheet
if intersect(activecell, .range("C:C")) is nothing then
'not in column C
else
'do what you want
end if
end with

This can come in handy if you want to adjust that range to check:

with activesheet
if intersect(activecell, .range("C:E, G1:H9, L:M")) is nothing then
'not in columns C:E, L:M or in G1:H9
else
'do what you want
end if
end with
 
Top