ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   ActiveCell in a Range? (https://www.excelbanter.com/excel-discussion-misc-queries/143683-activecell-range.html)

Filo

ActiveCell in a Range?
 
Hello-
I am trying to program a certain action if the activecell is inside a
certain range, and a different action if it is outside. How can I receive
some signal as to whether the activecell is within a certain range?
Below is a rough code description of what I am trying to do


If activecell is inside Range(A1:E77) then
....
else
.....

Please let me know if you would need more information. Thank you!!

Ron de Bruin

ActiveCell in a Range?
 
You can use intersect

If Not Application.Intersect(Range("A1:E77"), ActiveCell) Is Nothing Then
MsgBox "In the range"
Else
MsgBox "not in the range"
End If


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Filo" wrote in message ...
Hello-
I am trying to program a certain action if the activecell is inside a
certain range, and a different action if it is outside. How can I receive
some signal as to whether the activecell is within a certain range?
Below is a rough code description of what I am trying to do


If activecell is inside Range(A1:E77) then
...
else
....

Please let me know if you would need more information. Thank you!!


Trevor Shuttleworth

ActiveCell in a Range?
 
Sub InRange()
If Not Intersect(ActiveCell, Range("A1:E77")) Is Nothing Then
MsgBox "In Range"
End If
End Sub

Regards

Trevor


"Filo" wrote in message
...
Hello-
I am trying to program a certain action if the activecell is inside a
certain range, and a different action if it is outside. How can I receive
some signal as to whether the activecell is within a certain range?
Below is a rough code description of what I am trying to do


If activecell is inside Range(A1:E77) then
...
else
....

Please let me know if you would need more information. Thank you!!




Filo

ActiveCell in a Range?
 
Thank you both! I love this message board.

"Ron de Bruin" wrote:

You can use intersect

If Not Application.Intersect(Range("A1:E77"), ActiveCell) Is Nothing Then
MsgBox "In the range"
Else
MsgBox "not in the range"
End If


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Filo" wrote in message ...
Hello-
I am trying to program a certain action if the activecell is inside a
certain range, and a different action if it is outside. How can I receive
some signal as to whether the activecell is within a certain range?
Below is a rough code description of what I am trying to do


If activecell is inside Range(A1:E77) then
...
else
....

Please let me know if you would need more information. Thank you!!




All times are GMT +1. The time now is 05:52 AM.

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