+ Reply to Thread
Results 1 to 4 of 4

Test for "if selection includes cells outside range"

Hybrid View

  1. #1
    Registered User
    Join Date
    07-23-2008
    Location
    Camas, Wa
    Posts
    12

    Test for "if selection includes cells outside range"

    Using Excel 2003 I need an If statement to test if the current selection by the user includes cells outside a given range.

    In this example let's say my range is range("A1:E10")

    My code should be able to say something like:

    If [current selection includes cells outside of range("A1:E10")] then
    msgbox ("Sorry but this feature is not available for the cells you selected.")
    End If

    Can anyone suggest a way to do that?

    Thank you so much!!

    Roger
    Last edited by phenomenix; 08-01-2008 at 03:27 PM. Reason: Typo in title

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Maybe like this.
        Const sAdrs As String = "A1:E10"
        
        If Union(Selection.Cells, Range(sAdrs)).Address(0, 0) <> sAdrs Then
            MsgBox ("Sorry ...")

  3. #3
    Registered User
    Join Date
    07-23-2008
    Location
    Camas, Wa
    Posts
    12

    Thank you. It worked

    Your code worked like a champ. Thank you so much.

    I sometimes feel guilty that I don't have a practical way to thank a person for help like this.

    Best wishes,

    Roger

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Don't feel guilty; PayPal $5 to your favorite charity. Or mine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1