VBA problem

J

JP

I would like a macro to run only if the active cell is in a specific column.
I have tried:

If ActiveCell.Column="X" Then
run macro etc
End If

But this does not work.

I think the syntax above is incorrect. Would appreciate help in correcting
this.

JP
 
M

macropod

Hi JP,

You need to work the the column number, not it's letter. Thus:
If ActiveCell.Column = 24 Then
...
End If
 
D

Don Guillett

Sub colltrtonum()'works up to z
If Chr(ActiveCell.Column + 64) = "X" Then
MsgBox "OK"
Else
MsgBox "NOT col X"
End If
End Sub
 

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

Top