PC Review


Reply
Thread Tools Rate Thread

check that active cell is within a range

 
 
alstubna
Guest
Posts: n/a
 
      16th Feb 2008
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.
 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      16th Feb 2008
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.


 
Reply With Quote
 
alstubna
Guest
Posts: n/a
 
      16th Feb 2008
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.

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting the selected range and active cell of a non active worksheetsheet GerryGerry Microsoft Excel Programming 7 23rd Sep 2009 05:22 PM
macro to select range from active cell range name string aelbob Microsoft Excel Programming 2 14th Jul 2008 09:19 PM
Spell Check range and move to active cells Jay Microsoft Excel Programming 3 16th May 2006 11:04 PM
Verify Active Cell is within a Range that changes as cell is delet =?Utf-8?B?U2hhbm5vbg==?= Microsoft Excel Programming 2 11th Feb 2006 12:01 AM
How to check if each value in a cell range is contained in a second cell range? ModelerGirl Microsoft Excel Discussion 3 31st Jan 2006 12:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:41 PM.