+ Reply to Thread
Results 1 to 11 of 11

'un-select' an object on an Excel worksheet before ending a macro.

  1. #1
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    'un-select' an object on an Excel worksheet before ending a macro.

    I have a macro that modifies one of 5 objects on an Excel worksheet.
    After ending the macro, the object retains its 'handles' as being the selected one.
    How can I 'de-select' it while still in the VB macro?

  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,603

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    Select a cell on the worksheet. One idea is to save the location of the active cell before you start the macro and then re-select the saved location before you exit the macro.

    Please Login or Register  to view this content.

    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 Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    Do you need to select the object to work with it?
    If posting code please use code tags, see here.

  4. #4
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    Thanks
    I was considering that but was wondering if there was some other way.
    - Stu

  5. #5
    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,603

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    @Norie: good thought

  6. #6
    Forum Contributor dlow's Avatar
    Join Date
    08-12-2013
    Location
    EveryWhere
    MS-Off Ver
    Excel 2007, 2010
    Posts
    275

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    I think that there is "always" an active cell. You cant not have one, but like stated above you dont have to interact with it. You want to limit interaction between VBA & Excel, they are not 2 programs under 1 umbrella but 2 completely different programs that why there is a penalty to select/activate, ect..

  7. #7
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    Hi Norie,

    Is there a way to do the following without using 'select'?


    Please Login or Register  to view this content.

    I tried combining the first two lines but got an error.
    Please Login or Register  to view this content.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    Is btnName a button?

    If it is how did you create it?

    Can you post the rest of the code so we can see what newStyle, newSize etc are?

  9. #9
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    Hi Norie

    I'm using Excel 11 on a Mac; the workbook will be used on both Mac & Windows systems.

    Heres the full subprogram; the purpose is to set a specified button to have the new characteristics.

    Please Login or Register  to view this content.

  10. #10
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    Since its a single button, you don't need to use a shape range or selection
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  11. #11
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: 'un-select' an object on an Excel worksheet before ending a macro.

    many thanks mikerikson,

    That worked perfectly.
    I had tried .TextFrame but missed .Characters.

    Best wishes,
    - Stu

+ 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. Select dyanmic range with variable starting/ending cells VBA
    By km2013 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-12-2013, 12:54 PM
  2. Run Time error 1004 Method Select of Object Worksheet failed
    By AlexMach in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-14-2012, 03:07 AM
  3. VBA Select mutiple rows (ending range variable)
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-30-2011, 04:16 PM
  4. Ending an Excel Worksheet
    By skg1063 in forum Excel General
    Replies: 1
    Last Post: 02-11-2006, 10:55 AM
  5. [SOLVED] How do I initiate the windows printer select object in Excel macro
    By Mick B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2005, 06:06 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