VBA related to Excel - Cell range selections

J

Jason S

Hi, this is really a VBA question relating to EXCEL rather than Word, but I
couldn't find a good newsgroup for Excel VBA. But I'm sure VBA in Word and
Excel are identical, if not very similar.

Does anyone know some VBA code to simply check whether ot not a certain
range (e.g. A1:A6) of cells are currently SELECTED?

I need the code to be able to tell if certain cells on a spreadsheet are
selected or not. It should provide a True or False result.

Thanks,
Jason.
 
C

Chuck

Check out the .Address property in Excel VBE, then work with the Selection.
For instance, you can determine whether the selection address matches your
criteria, if so then do something, if not do something else. Note that
..Address has various optional parameters.

Dim strAddress As String

strAddress = "$F$2:$F$3"

If Selection.Address = strAddress Then
MsgBox "hi"
End If
 
H

Helmut Weber

Hi Jason,

If ActiveWindow.RangeSelection.Address = "$A$1" Then
MsgBox "true"
End If

But i'm sure there is better help in
microsoft.public.excel.programming
and
ExcelVBA and WordVBA are quite different, IMHO,
unless you think Word and Excel are very similar.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Keep your VBA code safe,
sign the ClassicVB petition www.classicvb.org
 
J

Jason S

Beatutiful! Thanks very much guys. You solved my problem =o)
Have a great day/night!

Jason.
 

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