+ Reply to Thread
Results 1 to 4 of 4

If selected range is not in desired range

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    If selected range is not in desired range

    I have a tool for my users to create a folder structure for them using a workbook. My macro begins with:
    Please Login or Register  to view this content.
    There are various formulas to help them construct the basic structure they want, then they need to Select the rows describing the desired structure, then press the "Go" button.

    I'm trying to make this as idiot-proof as I can. The desired rows should be in column B, starting at B10 and continuing down a number of rows (variable). How do I flash a warning if they've accidentally selected say, D5:E17, IE they selected something OTHER than their desired folder structure?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: If selected range is not in desired range

    I'm trying to make this as idiot-proof as I can.
    Good luck with that

    You can use the Selection Change event handler to monitor what cells are selected and the Change event handler to monitor changes to values (not formulas).


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: If selected range is not in desired range

    Hi,

    One way as the first bit of code in your 'Go' macro

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: If selected range is not in desired range

    Sorry it's taken me so long to get back to this thread. I used Richard's method as shown below. And thanks Richard; I learned something new. Usually when I have a check in a macro, if the check requires restarting I put "Exit Sub"; I never saw "End" used to exit a macro (shows how educated I am) so I was glad to learn that. Thanks to both of your for your help.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 03-02-2015, 11:18 AM
  2. [SOLVED] get the partner name from range of Partner name and rank to desired range formula
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2014, 11:46 AM
  3. [SOLVED] How to set range within a macro based on what range is selected on the worksheet
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2013, 12:49 PM
  4. [SOLVED] Dynamically add Border to desired range
    By AR-51 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-17-2013, 02:37 PM
  5. How do I edit a selected range then copy the range into an new sheet???
    By dwyborn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2005, 12:11 PM
  6. Compare a selected Range with a Named range and select cells that do not exist
    By PCLIVE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2005, 03:05 PM
  7. [SOLVED] resizing a range-What do I need to do to get the range to be resized as desired?
    By Tim Kredlo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2005, 04:05 PM

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