+ Reply to Thread
Results 1 to 18 of 18

Go to another worksheet and then come back to the original

  1. #1
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Go to another worksheet and then come back to the original

    I'm setting up a payroll for several employees in one workbook. I start from the particular employee's worksheet and then I need to go to another sheet where various information is stored and then come back to the original employee's sheet. The current macro works fine if the various information is stored on each employee's worksheet but I can't figure out how to go to another sheet and then come back to my active cell in employee sheet.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Go to another worksheet and then come back to the original

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    I appreciate your effort but that didn't work. Somehow, the macro doesn't like for me to go to another page to make my selection.

    Perhaps I need a totally different approach to my problem. Here's my situation. The payroll that I am trying to fix is for a trucking company. We have some hauls that the pay is figured on a per mile basis. Then we have some that are paid on a per load basis. There are several hauls on the per load basis that have various origin points and various destination points. For instance, I have origin points A, B and C and destinations X, Y and Z. I have a list that designates hauls of A-Z, B-Z, C-Y and pay is determined by the combination. There is no way to have a mathematical formula that determines the rates for the various combinations. It's simply going to be a list. I'm trying to avoid putting this list of pre-determined on the same sheet as each individual employee. The concern is future changes by folks that may not have a decent grasp of Excel. My thinking is, if I have the haul rates on one protected sheet, future changes to haul rates would be a simple modification to one sheet as opposed to making changes to each sheet.

    If any of you folks have a different procedural idea on how this could be accomplished, I'm all ears.

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

    Re: Go to another worksheet and then come back to the original

    What do you need to go to the other sheet for?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    That is where I would have all of the information for the loads stored. I can put the information for these loads on each individual employee's sheet but if I do, I am concerned about future changes. In other words, let's say that a new load comes along that is D-X and employee John Doe hauls that load. That D-X load gets put on John Doe's sheet but D-X doesn't get put on all of the other employee's individual sheets. I need all changes to be on sheet that can be selected from any of the other employee's sheets.

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

    Re: Go to another worksheet and then come back to the original

    So are you just going to the other sheet to get data?

    If you are then there's no need to activate/select the other sheet.

  7. #7
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    I'm not sure I understand how I could get the information from the other sheet without selecting(going to) the other sheet.

  8. #8
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    But yes, I am just going to the other sheet to get data.

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

    Re: Go to another worksheet and then come back to the original

    All you need to do is correctly reference the sheet/range.

    What's the name of the other sheet?

  10. #10
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    It is named "Spare"

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

    Re: Go to another worksheet and then come back to the original

    Could you give some information on what you actually want to do?

    Does the user actually need to select something on the 'Spare' sheet?

    What data is to be copied from that sheet and where is it to be copied to?

  12. #12
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    This is my current sheet.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    And yes, the user would select let's say, CC-PB under the Chips column. Then the macro would copy the information to the right of the CC-PB and bring it back to the "New Driver" tab and proceed with the rest of the macro.

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

    Re: Go to another worksheet and then come back to the original

    I'm a little confused.

    If I click one of the buttons on the New Driver sheet, goto the Spare sheet, select something from the Chips column and then press OK focus goes back the the New Driver sheet automatically.

  15. #15
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    I get a
    Run Time Error 1004
    Select method of Range Class failed.

    When I click debug, it goes to

    userResponse.Select

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

    Re: Go to another worksheet and then come back to the original

    The reason for that error is because userResponse is the range you've selected on the 'Spare' sheet and focus is now on the 'New Driver' Sheet.

    Try changing the code to this.
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    05-03-2014
    Location
    USA
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    42

    Re: Go to another worksheet and then come back to the original

    WOW! I believe that is going to work fine. I certainly hope that you understand that my clicking "Add Reputation" for you is not even a fraction of the appreciation that I have for the help that you have given me.

    Be blessed today!

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

    Re: Go to another worksheet and then come back to the original

    Glad that worked.

    By the way, if you are interested I managed to cut down the code to just one sub rather than a separate sub for each day.

    Nothing complicated really, just a few tweaks to one of the existing subs, a bit of button renaming and macro reassigning.

+ 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] VBA to go back to original worksheet one started with
    By D_Step in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2012, 04:44 PM
  2. how to go back to original wrksht that calls another worksheet
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2012, 10:24 AM
  3. Macro goes back to the original tab.
    By Nashy19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2008, 08:15 AM
  4. Ho to go back to the original sheet
    By c991257 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-10-2007, 04:13 PM
  5. Back to original Formating
    By parteegolfer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2006, 03:01 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