+ Reply to Thread
Results 1 to 9 of 9

Do something when all cells are selected

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    42

    Do something when all cells are selected

    Hello,

    I have a macro that looks like this,

    Please Login or Register  to view this content.
    This helps prevent users from selecting more than one cell at a time.
    However I am looking to handle a scenario when the user tries to select all the cells on the sheet.

    Does any body know how i could write that, i.e. if user selects all the cells on the page then do X?

    Thanks
    Matt

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Do something when all cells are selected

    Try this:
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Do something when all cells are selected

    Try this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Do something when all cells are selected

    xla, that won't work.

    I like 6SJ's suggestion. Another way:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Do something when all cells are selected

    @ shg - I tried it before posting But your way is better
    Last edited by xladept; 08-11-2017 at 12:01 PM.

  6. #6
    Registered User
    Join Date
    06-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: Do something when all cells are selected

    thanks for your feedback guys, both options worked for my version of excel.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Do something when all cells are selected

    Curious. I get an overflow error with all cells selected, because Count is Variant/Long.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Do something when all cells are selected

    @ shg - That's why I used the On Error.

    @ ola7mat - You're welcome and thanks for the rep!

    Much neater with shg's code line:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Do something when all cells are selected

    Quote Originally Posted by xladept View Post
    @ shg - That's why I used the On Error.
    Completely missed that, sorry.

+ 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. [SOLVED] Pasting an image into selected merged cells. VBA to size automatically to selected range
    By DCC_PD in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-28-2015, 09:57 AM
  2. [SOLVED] Join and Merge Selected Selected Cells
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2014, 06:54 PM
  3. Loop backwards through selected range - delete entire row from selected cells
    By scottbass in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2014, 09:21 AM
  4. Replies: 2
    Last Post: 08-28-2011, 02:39 AM
  5. copy data from selected cells , in selected row and paste it to ms word table ?
    By aaashaaa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2010, 03:25 PM
  6. Replies: 1
    Last Post: 06-05-2006, 03:55 PM
  7. Macro to take selected cells times a selected cell
    By Craig in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-23-2005, 08:05 PM

Tags for this Thread

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