Solved

Help with Macro to Multiple Tabs Excel

Posted on 2016-11-02
2
43 Views
Last Modified: 2016-11-03
Hello,

Can someone please help me create a macro that will iterate through a link in excel and create several tabs based on values in the link.  In the attached example, I have placed a data validation list in cell B4 as a drop down.  I want to iterate though the values in the link and create tabs of all the values contained in the link.

Thanks in advance for your help
Report-Out.xlsx
0
Comment
Question by:fb1990
2 Comments
 
LVL 21

Accepted Solution

by:
Ejgil Hedegaard earned 500 total points
ID: 41871230
Check attached.
Macro in Module1.

Option Explicit

Sub CreateReports()
    Dim wsReport As Worksheet, ws As Worksheet
    Dim ListName As Variant
    Dim i As Integer
    
    Application.ScreenUpdating = False
    
    Set wsReport = Worksheets("Report")
    For Each ListName In [NamedList]
        wsReport.Range("C2") = ListName
        wsReport.Copy After:=Sheets(ThisWorkbook.Sheets.Count)
        i = 0
        For Each ws In ThisWorkbook.Worksheets
            If Left(ws.Name, Len(ListName)) = CStr(ListName) Then
                i = i + 1
            End If
        Next ws
        If i > 0 Then
            ActiveSheet.Name = ListName & " " & CStr(i + 1)
        Else
            ActiveSheet.Name = ListName
        End If
    Next ListName
End Sub

Open in new window

Report-Out.xlsm
0
 
LVL 1

Author Closing Comment

by:fb1990
ID: 41872035
Thank you very much.  It worked as expected...
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question