+ Reply to Thread
Results 1 to 3 of 3

Allowing macro to run only when ALL selected cells are withing a range.

  1. #1
    Registered User
    Join Date
    04-07-2017
    Location
    U.S.
    MS-Off Ver
    2010
    Posts
    16

    Allowing macro to run only when ALL selected cells are withing a range.

    Currently I am trying to run a program on when all the selected cells are withing a certain range. Using Intersect(ActiveCell, Range) works but you can select as many cells as you want that are not in the range and the program will still run as long as the activecell is in the range. Using Selection instead of ActiveCell will run as long as one of the selections is in the range.

    What I am trying to accomplish is to be able to select as many cells as I want inside the range and have the program run on these cells. If runs a formatting program utilizing cell offsets from the range.

    An example of this code is:
    Please Login or Register  to view this content.
    Which would call something like:
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Allowing macro to run only when ALL selected cells are withing a range.

    Use code like this:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    04-07-2017
    Location
    U.S.
    MS-Off Ver
    2010
    Posts
    16

    Re: Allowing macro to run only when ALL selected cells are withing a range.

    Ok so it looks like I have to compare to see if all are within the selection. Its amazing how something so simple starts to blow up just from one little issue.

    Thank you for the super quick reply also. You must have not had to think at all how to figure this out this out.

+ 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. Setting up Macro using external data range and allowing others to use this macro
    By Graham888 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2016, 04:41 PM
  2. [SOLVED] Count hidden cells withing range
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-22-2015, 11:43 AM
  3. [SOLVED] Recording New Macro For a Randomly Selected Range Of Cells
    By butterscotch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2015, 12:43 PM
  4. VBA code to loop through a range of selected cells, to add to my macro
    By craig schultz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2014, 10:30 AM
  5. Only allowing a range of cells to be double clicked
    By joleme in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2014, 04:43 PM
  6. Selecting cells withing a date range
    By v7e8n3e1z2u8e5l in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 06:27 AM
  7. Macro or function that changes value of selected range or ranges of cells
    By ychartra01 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-06-2009, 06:11 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