ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell lies within range (https://www.excelbanter.com/excel-programming/332060-cell-lies-within-range.html)

Kaval

Cell lies within range
 
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

Bernie Deitrick

Cell lies within range
 
Kaval,

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

HTH,
Bernie
MS Excel MVP


"Kaval" wrote in message
...
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




Vasant Nanavati

Cell lies within range
 
For example:

MsgBox Not Intersect (Range("A1"), Range("A2:Z100")) Is Nothing

--

Vasant

"Kaval" wrote in message
...
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




Norman Jones

Cell lies within range
 
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

---
Regards,
Norman



"Kaval" wrote in message
...
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





All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com