Return the range of active cell

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,467
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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

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,758
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,112,883
Messages
5,543,017
Members
410,583
Latest member
gazz57
Top