+ Reply to Thread
Results 1 to 14 of 14

Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

  1. #1
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Hi,

    I am looking for a macro that returns the selected cell to cell A1 on every sheet and ends on the first sheet. The names of the sheets are ever-changing so I need it to be relative with no specific naming.

    Thank you for your help. I really appreciate it.
    Last edited by Jason Carlos; 05-01-2014 at 07:23 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Try the following (and check for errors first - have no excel installed on this computer to try myself):
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Hey Kaper,

    I really appreciate the help. I plugged it in, the macro takes me to the first worksheet but the cell remains selected on which ever cell was previously selected.

    I am not sure what to change in the macro.

    Any suggestions?

  4. #4
    Registered User
    Join Date
    05-19-2013
    Location
    Helsinki, Finland
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Please Login or Register  to view this content.
    [/QUOTE]

  5. #5
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Thank you laripa but when I tied this Macro, I got :

    "Object variable or With Block variable not set"

    On the Line:

    Set MyCell = wb.sheets(1).Range("A1")

  6. #6
    Registered User
    Join Date
    05-19-2013
    Location
    Helsinki, Finland
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    I don't have Excel in front of me but try the below:

    Quote Originally Posted by laripa View Post
    Please Login or Register  to view this content.
    [/QUOTE]

  7. #7
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Close!

    That one took me to the first Sheet but did not select A1 in all of the other sheets.

  8. #8
    Registered User
    Join Date
    05-19-2013
    Location
    Helsinki, Finland
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    I should have read carefully your post. The below should work.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Laripa you are a Boss!

    That worked perfectly, thank you for the help!

  10. #10
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Wait I apologize I spoke to soon. It worked the first time and then didn't work after that. It is still not returning the selected cell to A1 on all pages.

    I have the macro saved in my personal workbook if that makes a difference.

  11. #11
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Jason--
    I tested laripa's code running it from personal.xlsb and from a test worksheet and it worked repeatedly without error. Perhaps you should upload your worksheet for examination to determine if there are other issues.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  12. #12
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    I am attaching the example workbook I am using.

    It is a simple workbook that says Test on Each page and I made sure that active cell is not A1.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    I have created the Macro that works for me. Thank you everyone for the help it got me on the right track! It is:

    Please Login or Register  to view this content.
    Last edited by alansidman; 05-01-2014 at 08:50 PM. Reason: added code tags

  14. #14
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Return Selected Cell to Cell A1 on Every Sheet/Tab - VBA Macros

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between
    Please Login or Register  to view this content.
    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)

+ 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. Macros run from selected cell
    By A-mac72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-15-2012, 10:35 AM
  2. Return selected cell from Combo box
    By Jollyfrog in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-06-2010, 01:27 PM
  3. Disabling macros within a selected row/cell range?
    By PcKid888 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2010, 11:23 PM
  4. Trying to get pop up of calendar after cell is selected using macros
    By copleyr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-01-2009, 08:42 AM
  5. [SOLVED] Can macros output to a cell selected prior to running it?
    By winnie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-18-2005, 10:06 AM

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