check that active cell is within a range
Hello All
Trying to modify a macro. The macro is attached to a forms button. The macro does stuff based on the active cell. When a user clicks the button to run the macro I need to pop-up a message box if the active cell isn't within a named range Table1 (A1:R18) then exit the sub. Thanks for any assistance you can offer. |
check that active cell is within a range
You can use the Intersect method to test that....
If Application.Intersect(ActiveCell, Range("A1:R18")) Is Nothing Then MsgBox "The active cell is not within the range of A1:R18" End If Rick Trying to modify a macro. The macro is attached to a forms button. The macro does stuff based on the active cell. When a user clicks the button to run the macro I need to pop-up a message box if the active cell isn't within a named range Table1 (A1:R18) then exit the sub. Thanks for any assistance you can offer. |
check that active cell is within a range
Thanks Rick, works great.
"Rick Rothstein (MVP - VB)" wrote: You can use the Intersect method to test that.... If Application.Intersect(ActiveCell, Range("A1:R18")) Is Nothing Then MsgBox "The active cell is not within the range of A1:R18" End If Rick Trying to modify a macro. The macro is attached to a forms button. The macro does stuff based on the active cell. When a user clicks the button to run the macro I need to pop-up a message box if the active cell isn't within a named range Table1 (A1:R18) then exit the sub. Thanks for any assistance you can offer. |
All times are GMT +1. The time now is 02:11 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com