Solved

Help with Macro to Multiple Tabs Excel

Posted on 2016-11-02
2
36 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now