+ Reply to Thread
Results 1 to 6 of 6

Select last sheet that had focus

  1. #1
    Registered User
    Join Date
    08-23-2011
    Location
    NYC
    MS-Off Ver
    Excel 2019/O365
    Posts
    60

    Thumbs up Select last sheet that had focus

    Hello,

    So, this is something I asked about here.

    Tiger gave some advice that gave me an idea:

    Please Login or Register  to view this content.

    So my thought is that I could use two macros. The first would assign the original active sheet to ws and then paste the string value (sheet name) to a cell on the 'multiple paste' sheet.

    Then once the values are inputted on 'multiple paste' sheet the second macro will return to the sheet the first macro was ran from and paste the concatenated values.


    My attempts so far have been unnsuccessful. I thought something like this would work, but it did not:

    Please Login or Register  to view this content.

    So as usual any help would be greatly appreciated.

    -BC
    Attached Files Attached Files
    Last edited by Internoob2; 09-07-2011 at 10:31 AM.

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

    Re: Select last sheet that had focus

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

  3. #3
    Registered User
    Join Date
    08-23-2011
    Location
    NYC
    MS-Off Ver
    Excel 2019/O365
    Posts
    60

    Red face Re: Select last sheet that had focus

    Thank you Shg.

    Just one more question.

    Now how can I use the sheet name from f4 to go back to that sheet and paste?

    the code I use now has the sheet name hard-coded:

    Please Login or Register  to view this content.
    How do I assign the string from f4 as a worksheet name (so I can return the focus there)?

    -BC


    P.S. Thank you for your help and patience I am still very much a beginner here.

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

    Re: Select last sheet that had focus

    Your code is written so that it pastes in whatever is the active cell on Data Sheet. That's bad for two reasons: it's ambiguous, and requires that you select the sheet before pasting.

    You can instead paste directly into a cell without selecting:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-23-2011
    Location
    NYC
    MS-Off Ver
    Excel 2019/O365
    Posts
    60

    Unhappy Re: Select last sheet that had focus

    I understand, however for this application it will be pasting in the last cell selected on the previous sheet. (Sometimes it will be pasting to education, other times to work, activities, or interest).

    So this way whatever the last cell was selected when the sheet is selected again the desired cell is already selected.

    I am curious to know how to assign the sheet name from f4 back to the 'ws' variable, so this admittedly ambiguous process can be used on multiple sheets and fields. It doesn't seem to hard but I can't figure it out. I tried this:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-23-2011
    Location
    NYC
    MS-Off Ver
    Excel 2019/O365
    Posts
    60

    Thumbs up Re: Select last sheet that had focus

    So, I came up with a solution from reading another forum, here. I have also attached a copy of a sample sheet with my solution.

    Thank you for pointing me in the right direction. So from the sheet I am entering on with the desired cell selected I run 1st macro (ctrl+d), then copy and paste the multiple values to column A and run second macro (ctrl+f).

    This will work for any new sheets added! A bit convoluted? Yes, however it suits my purposes here.


    Thanks again. I love this site/community,
    -BC
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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