+ Reply to Thread
Results 1 to 6 of 6

Switch from Active Window to Variable Window/Rename Varaible Sheet

  1. #1
    Registered User
    Join Date
    06-07-2005
    Posts
    6

    Switch from Active Window to Variable Window/Rename Varaible Sheet

    FYI, my experience with macros is copying and pasting code from someone with a similar problem and then slightly modifying it for my own needs. I may not get all the lingo you throw at me.

    I work with a program that creates an Excel file. It inputs data and creates a worksheet named after the file itself (the variable). The following code is part of a larger macro, but the code below is supposed to open a specific file, copy and paste the a range in a new sheet (named Sheet1), rename "Sheet1" to "Sheet2", and then rename the variable sheet to "Sheet1."

    I'm having problems switching from the active window to the variable window and I can predict that I will have the same issues when renaming the variable sheet.

    Thanks in advance.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Switch from Active Window to Variable Window/Rename Varaible Sheet

    I'm not quite clear where you are copying from, and to...

    You start with Workbook1 open, which contains your code.
    You want to:
    - open Workbook2
    - copy some values from the existing worksheet in Workbook2 (which has a variable name), to a new sheet in Workbook2
    - rename both worksheets in Workbook2
    - close Workbook2

    Is that correct?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  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: Switch from Active Window to Variable Window/Rename Varaible Sheet

    What names/variables etc do you know?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    06-07-2005
    Posts
    6

    Re: Switch from Active Window to Variable Window/Rename Varaible Sheet

    "I'm not quite clear where you are copying from, and to...

    You start with Workbook1 open, which contains your code.
    You want to:
    - open Workbook2
    - copy some values from the existing worksheet in Workbook2 (which has a variable name), to a new sheet in Workbook2
    - rename both worksheets in Workbook2
    - close Workbook2

    Is that correct? "


    Code is currently stored in a personal workbook...different issue for a different day.

    Workbook1 has the variable name and worksheet. Workbook2 is opened,copied, and pasted into Workbook1. Sheet pasted into WB1 to be renamed "Sheet2." Variable worksheet to be named "Sheet1."

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Switch from Active Window to Variable Window/Rename Varaible Sheet

    Sorry, still not entirely clear. Do you start with Workbook1 open, and the 'variable' sheet active?

    If that IS the case, then try something like this:

    Please Login or Register  to view this content.


    If it is NOT the case that the 'variable' worksheet is the active sheet - then how are you identifying the 'Workbook1' workbook / worksheet?

  6. #6
    Registered User
    Join Date
    06-07-2005
    Posts
    6

    Re: Switch from Active Window to Variable Window/Rename Varaible Sheet

    Quote Originally Posted by Olly View Post
    Sorry, still not entirely clear. Do you start with Workbook1 open, and the 'variable' sheet active?

    If that IS the case, then try something like this:

    Please Login or Register  to view this content.


    If it is NOT the case that the 'variable' worksheet is the active sheet - then how are you identifying the 'Workbook1' workbook / worksheet?

    Thanks, Olly

    After using your code and slightly modifiying some other code I didn't provide earlier, I was able to get it working. A+, buddy.

+ 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. use VBA to switch to an new IE window that has opened behind main IE window.
    By Andy Mcc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-26-2015, 09:16 AM
  2. resize active window ie: add to the height of the active window
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-07-2014, 01:55 AM
  3. need help in making the current window as active window.
    By ashvija in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-27-2012, 06:04 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