Return the range of active cell

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,477
Is it possible for VBA to check which cell is active?

If the active cell is A9 I want to fire off another procedure other just carry on with code.

I thought the following would have worked
Code:
If Range(ActiveCell) = Range("A9") Then
    MsgBox ("Range A9")
    Else
    MsgBox ("Range not A9")
End If

Thanks
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

DominicB

Well-known Member
Joined
Oct 3, 2005
Messages
1,569
Good afternoon mikeymay

How about :

Code:
If ActiveCell.Address = "$A$9" Then
    MsgBox ("Range A9")
    Else
    MsgBox ("Range not A9")
End If

HTH

DominicB
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,760
Office Version
  1. 365
Platform
  1. Windows
Hi

Try:
Code:
Sub HF()
If ActiveCell.Address(rowabsolute, columnabsolute) = "A9" Then
MsgBox "Yeeeessssss"
Else
MsgBox "Nope"
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,119,022
Messages
5,575,625
Members
412,680
Latest member
TSpan
Top