Cell lies within range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I think I have seen an elegant way of determining if a particular cell lies
within a particular range. eg. does cell(x,y) lie inside range(a:b)

Any ideas?

Thanks, Kaval
 
Kaval,

MsgBox Not (Intersect(Cells(x, y), Range("a:b")) Is Nothing)

HTH,
Bernie
MS Excel MVP
 
Hi Kaval,

Try something like:

Sub Tester09()
Dim rng As Range
Dim rcell As Range

Set rng = Range("TEST")
Set rcell = Range("A2")

If Not Intersect(rcell, rng) Is Nothing Then
MsgBox rcell.Address(0, 0) & " lies in the named " _
& rng.Name.Name & " range"
Else
'It does not!

End If

End Sub
 

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