Make macro that will create new .xlsx, iteratively, from dropdown

Nordmane

New Member
Joined
Mar 26, 2020
Messages
12
Office Version
  1. 2016
Platform
  1. Windows
I have a Dashboard that displays graph and text dynamically filled upon selection of DataValidation list in cell A1 (on Dashboard).


So I need to create a macro that will cycle through all entries in the dropdown, creating a new .xlsx with the same formatting for the user.

User will activate macro and be prompted for path/folder in which they would like to store their files. Each dashboard would be a uniquely named .xlsx (ideally the file name would contain the name which is the value selected from the dropdown in the Dashboard.


I have a VERY beginning understanding of vba and haven't written loop code nor done much other than record a macro and tweak the code to my situation. I've seen a few other threads on this topic but couldn't make sense of any of it, so please, if anyone can help, please know that I'm a beginner here. Thank you VERY much for any and all help!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Where does the Dropdown get its list from?

Is each new workbook a copy of the workbook containing the dropdown thereby retaining the same formatting that you mention?

Having multiple workbooks can lead to management issues.

Unles there is a good reason for having these, keeping all of the data / functionality in one workbookk is a good idea.
 
Upvote 0
Hi,

Thanks for your reply!

I am looking for something like this:

VBA Code:
Sub DashboardToPDF()
Dim FolderName As String, fName As String
Dim inputRange As Range, r As Range, c As Range

Application.ScreenUpdating = False
'''' Open file dialog and choose folder
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = True Then
FolderName = .SelectedItems(1) & "\"
Else
Exit Sub
End If
End With

'''' Location of DataValidation cell
Set r = Worksheets("Dashboard").Range("C1")
'''' Get DataValidation values
Set inputRange = Evaluate(r.Validation.Formula1)

'''' Loop through DataValidation list
For Each c In inputRange
r.Value = c.Value
fName = c.Value
'''' Save as pdf
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=FolderName & fName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Next c
Application.ScreenUpdating = True
End Sub

The drop down gets it's list from a separate sheet in the workbook and the dashboard is updated using yet another separate sheet containing a detail file.

There is an important reason for having each dashboard in it's own new workbook. This is necessary for our clients.

Thanks so much for reaching out! I appreciate any and all help!
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,655
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top