+ Reply to Thread
Results 1 to 9 of 9

Loop to create Multiple Tabs from 2 Master Tabs

  1. #1
    Forum Contributor
    Join Date
    02-04-2015
    Location
    India
    MS-Off Ver
    365 (2202)
    Posts
    226

    Loop to create Multiple Tabs from 2 Master Tabs

    Hello Experts,

    Within my excel workbook, I've 2 tabs i.e. Master and Raw.

    My requirement is to create 8 different tabs based on Master and Raw tabs.

    For instance: Initially when we run the macro, a duplicate tabs should get created of other said 2 tabs, then the tabs should get renamed to 1.0 and 1.0.

    Again on second loop, new duplicate tabs should get created of Master and Raw tab, and it should get renamed to 2.0 and 2.1.

    And so on till 8.0 - 8.1

    See attached for your reference. I've added only 6 tabs i.e. till 3.1.

    Appreciate your help in advance. Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Loop to create Multiple Tabs from 2 Master Tabs

    Please Login or Register  to view this content.
    If someone has helped you then please add to their Reputation

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this !


    According to the attachment a VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
             
    Dim P%, S%
        
    With Application
            
    .ScreenUpdating False
        
    If Sheet1.Index 1 Then
            
    .DisplayAlerts False
             Sheets
    (Evaluate("TRANSPOSE(ROW(1:" Sheet1.Index "))")).Delete
            
    .DisplayAlerts True
        End 
    If
        For 
    1 To 8
        
    For 0 To 1
            Sheets
    (Sheet1.Index S).Copy Sheet1
            ActiveSheet
    .Name "." S
        Next S
    P
            
    .ScreenUpdating True
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon ? Add Reputation ? !

  4. #4
    Forum Contributor
    Join Date
    02-04-2015
    Location
    India
    MS-Off Ver
    365 (2202)
    Posts
    226

    Re: Loop to create Multiple Tabs from 2 Master Tabs

    Thanks!

    Both the above code did worked for me.

    As there are still more loops to add to my actual excel worksheets, I'll try from my end.

    Thank you, so much for for quick response. Cheers

  5. #5
    Forum Contributor
    Join Date
    02-04-2015
    Location
    India
    MS-Off Ver
    365 (2202)
    Posts
    226

    Re: Loop to create Multiple Tabs from 2 Master Tabs

    Oh! I got a change in my requirement. My Apologize!

    As we have 2 tabs i.e. Master and Raw - on 1st loop - we should get a duplicate tabs of Master and Raw and they should get renamed

    Master tab should get renamed to M4908 and Raw tab should get renamed to M4908-P1

    on Second Loop

    Master tab should get renamed to M7023 and Raw tab should get renamed to M7023-P1

    There will be overall 16 tabs to be created after each loop i.e. 8 tabs of Master and 8 tabs of Raw

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Loop to create Multiple Tabs from 2 Master Tabs


    As I can't code any guessing challenge ...

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Last but not least ?


    According to your post #5 my VBA demonstration revised in order to create both first iterations
    as a beginner starter you can easily amend for what you forgot / misexplained :

    PHP Code: 
    Sub Demo1r()
            
    Dim VS%
        
    With Application
            
    .ScreenUpdating False
        
    If Sheet1.Index 1 Then
            
    .DisplayAlerts False
             Sheets
    (Evaluate("TRANSPOSE(ROW(1:" Sheet1.Index "))")).Delete
            
    .DisplayAlerts True
        End 
    If
        For 
    Each V In [{"M4908","M7023"}]
        For 
    0 To 1
            Sheets
    (Sheet1.Index S).Copy Sheet1
            ActiveSheet
    .Name IIf(S"-P1""")
        
    Next SV
            
    .ScreenUpdating True
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon ? Add Reputation ? !

  8. #8
    Forum Contributor
    Join Date
    02-04-2015
    Location
    India
    MS-Off Ver
    365 (2202)
    Posts
    226

    Re: Loop to create Multiple Tabs from 2 Master Tabs

    Hi Marc,

    Your code works, but only when I have 2 active sheets in the workbook.

    In my actual Excel, I have multiple other tabs as well. When I run this code, all the other tabs are getting deleted, except the Master and Raw tab.

    How can we add a line of code, to create a duplicate tabs for specific tabs. Something as below:
    PHP Code: 
    Worksheets("Master").Copy After:=Worksheets(Sheets.Count

  9. #9
    Forum Contributor
    Join Date
    02-04-2015
    Location
    India
    MS-Off Ver
    365 (2202)
    Posts
    226

    Re: Loop to create Multiple Tabs from 2 Master Tabs

    Hi Marc,

    I amended the code as per my requirement and was able to achieve what I was looking for.

    Thank you once again. Well Appreciated.

+ 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 Create 3 new tabs from master sheet
    By Bootkie2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2019, 09:55 AM
  2. Replies: 1
    Last Post: 12-15-2018, 11:06 PM
  3. [SOLVED] Create a master list of names from multiple tabs
    By rob.callaghan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-31-2017, 10:51 AM
  4. collating multiple tabs within same workbook to create a master/summary tab
    By xotrujillo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-02-2016, 05:15 PM
  5. Can you auto create multiple tabs from enterting data in a master sheet's column?
    By ambermorr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2013, 07:28 AM
  6. Create additional tabs automatically based on input from master sheet
    By davidshluger in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-30-2010, 12:02 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