Testing if a cell is within a range

  • Thread starter Thread starter Conan Kelly
  • Start date Start date
C

Conan Kelly

Hello all,

Is it possible to test if the active cell is within a certain range?

I have a short list of categories, A36:A47, that I have given the range the name "CategoriesList". In the
"Worksheet_SelectionChange" event, I want to test to see if the new active cell is within the CategoriesList range and if it is, set
another cell on the worksheet to the same value as the active cell.

If it is possible, please provide sample code.
 
Try this...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A36:A47")) Is Nothing Then
MsgBox Target.Address
End If
End Sub
 
If Not Intersect(Target,Range("CategoriesList")) Is Nothing Then
'do your thing

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Conan Kelly said:
Hello all,

Is it possible to test if the active cell is within a certain range?

I have a short list of categories, A36:A47, that I have given the range
the name "CategoriesList". In the
"Worksheet_SelectionChange" event, I want to test to see if the new active
cell is within the CategoriesList range and if it is, set
 
Jim,

Thank you for your feedback. You and Bob Phillips had the same response. It worked beautifully.

Thanks again for all of your help,

Conan
 
Bob,

Thank you for your feedback. You and Jim Thomlinson had the same response. It worked beautifully.

Thanks again for all of your help,

Conan
 

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

Back
Top