VBA problem

  • Thread starter Thread starter JP
  • Start date Start date
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
 
Hi JP,

You need to work the the column number, not it's letter. Thus:
If ActiveCell.Column = 24 Then
...
End If
 
Sub colltrtonum()'works up to z
If Chr(ActiveCell.Column + 64) = "X" Then
MsgBox "OK"
Else
MsgBox "NOT col X"
End If
End Sub
 
Back
Top