If Statment - Active Cell Column Address

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top