+ Reply to Thread
Results 1 to 5 of 5

Help with determining if selection is contained in local named range

  1. #1
    Registered User
    Join Date
    02-23-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    3

    Help with determining if selection is contained in local named range

    New to the forum, new to vba programming, and hoping to get some help.

    I have a workbook with multiple worksheets. There is a local range on each worksheet with the same name (User_Data). I have code that limits users' editing to just the User_Data area. Since the User_Data range is local, I can use the same code on all worksheets and everything works fine. However, I now need to add more ranges to each worksheet. The ranges are not contiguous and vary in size, so I need to give them different names. In addition, each worksheet could have a different number of ranges. I decided to name the ranges User_Data1, User_Data2, etc. I want to keep the names the same so my code is universal across all sheets. I added some code to check if the user selection is contained inside one of the ranges (just like I did with the original) and tried to check all User_DataX ranges, keeping in mind that the number of ranges is variable by sheet. However, my code (some of which is borrowed) doesn't work and I am stuck (keep in mind I'm relatively new to vba, but reading like a madman!!). Below is my code. Also, I need to shrink my User_DataX range by one row on the top and one row on the bottom before I check to see if the selection is contained in that range. Thanks in advance for any suggestions.

    Please Login or Register  to view this content.
    Last edited by MI223; 03-08-2013 at 11:18 AM.

  2. #2
    Registered User
    Join Date
    02-23-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Help with determining if selection is contained in local named range

    Bump no response

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Help with determining if selection is contained in local named range

    Hello MI223
    ,

    Welcome to the Forum!

    Here is an example macro that trims the top and bottom rows froma range.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    02-23-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Help with determining if selection is contained in local named range

    LR - Thanks for the reply. That part of the code works well now. I still haven't figured out how to use a wildcard to search through the locally named ranges on only the active sheet and ignore the other sheets as described in the OP. Anybody have any ideas?

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Help with determining if selection is contained in local named range

    Hello MI223,

    If you provide an example of what you want to do with the named ranges, it should be easy to provide you with a solution.

+ 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