+ Reply to Thread
Results 1 to 9 of 9

Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

  1. #1
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    Hi

    I have started writing a macro with the code as follows:

    Please Login or Register  to view this content.
    Let's say sheets 1-3 in the Template workbook have been renamed Jan-17, Feb-17 & Mar-17. What I want to do is copy from the 'File' workbook the macro has opened the tabs which match the names of these tabs (i.e. Jan-17 etc.) and paste in to a cell (let's say A4) of the respective tabs of the Template workbook. This is a template so the names the tabs will change whenever the macro is run.

    I hope this makes sense.

    Thanks in advance

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

    Re: Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    Will each worksheet in the template workbook always have a corresponding worksheet in the other file?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Re: Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    It will indeed.

  4. #4
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Re: Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    *edit * Not all, only the first 3 sheets.
    Last edited by stevoDE; 06-27-2017 at 10:38 AM.

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

    Re: Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    Perhaps something like this.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Re: Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    Is that going to work off the back of my edited post information Norie? I'm guessing not as there won't a corresponding sheet for the other tabs after sheet3.
    Last edited by stevoDE; 06-27-2017 at 10:53 AM.

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

    Re: Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    No, didn't see the edit.

    Try this.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Re: Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    Thanks Norie. That seems to work.

    Another couple of questions if you don't mind. Does the variables wsDst and wsSrc do/mean something specific as I get an error when I replace those variables with my own? I notice there is no use of paste or destination:=? If I wanted to only paste the values and formats, how would I amend the code here?

  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: Copying tabs (which mach the name of tabs in cuurent workbook) from another workbook

    The names of the variables aren't really relevant but I tend to try and use something that's kind of descriptive, eg wsDst- destination worksheet, wsSrc - source worksheet.

    In the code it's a straight copy which only requires one argument, destination, so being lazy I've ommitted the Destination:= part.

    If you wanted to copy and then paste values/formats/whatever it would look something like this.
    Please Login or Register  to view this content.

+ 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. Copying tabs to new workbook with Macro
    By dramond1975 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2017, 08:09 AM
  2. Creating new workbook using a template and copying tabs
    By JohnDoh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-27-2015, 03:17 AM
  3. [SOLVED] VBA code to merge multiple sheet with multiple tabs into one workbook in different tabs
    By Jagdev in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-06-2015, 07:42 AM
  4. Linking One Workbook with Multiple Tabs to Master Workbook Formula
    By Scholzie220 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-27-2015, 09:13 AM
  5. [SOLVED] Extract data from a workbook with multiple tabs, into a workbook with corresponding tabs
    By krackaberr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-28-2013, 11:54 AM
  6. Problem copying multiple tabs to a new workbook
    By bleat in forum Excel General
    Replies: 1
    Last Post: 05-23-2012, 06:09 AM
  7. Select sheet tabs in workbook & save to separate workbook files
    By stratocaster in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-01-2006, 11:40 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