SuperSquirrel
New Member
- Joined
- Aug 18, 2017
- Messages
- 9
So I have a spreadsheet that has a drop down of 300 schools.
Depending on what you select in that drop down, the table below magically updates using vlookups. There is a graph that is linked to that data.
https://ibb.co/jaeCKb
so the yellow is the drop down E2
The ask of me is to print (PDF) 300 graphs - one per school so schools know where they stand
my thought was to use VBA or a macro to print the page, then to navigate to the 2nd item in the drop down, print that, then navigate to the 3rd item, then print that, etc. etc.
I found this online:
Sub loopList()
Dim inputRange As range
'get the list of drop down list
Set inputRange = Evaluate(range("E2").validation.Formula1)
'loop the value in drop down list
For Each Cell In inputRange
'print to pdf
pdfName = Cell.Value 'file name
fileSaveName = Application.GetSaveAsFilename(pdfName, _
fileFilter:="PDF Files (*.pdf), *.pdf")
If fileSaveName <> False Then
'active the sheet you want to print
ActiveWorkbook.Sheets(pdfName).Activate
activeSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End If
Next
End Sub
but I don't know VBA, so I don't know how to make it work for me.
Using that, it works, for one. then crashes. It does not move to the 2nd option in the drop down
Also, that requires me to press "Enter" to save. It there a way for it to save automatically so I can press run and go to lunch and have everything saved, or do I have to press Enter 300 times?
Anywhoo -- experts please help this awesome vlookuper but horrible vbaer!
Depending on what you select in that drop down, the table below magically updates using vlookups. There is a graph that is linked to that data.
https://ibb.co/jaeCKb
so the yellow is the drop down E2
The ask of me is to print (PDF) 300 graphs - one per school so schools know where they stand
my thought was to use VBA or a macro to print the page, then to navigate to the 2nd item in the drop down, print that, then navigate to the 3rd item, then print that, etc. etc.
I found this online:
Sub loopList()
Dim inputRange As range
'get the list of drop down list
Set inputRange = Evaluate(range("E2").validation.Formula1)
'loop the value in drop down list
For Each Cell In inputRange
'print to pdf
pdfName = Cell.Value 'file name
fileSaveName = Application.GetSaveAsFilename(pdfName, _
fileFilter:="PDF Files (*.pdf), *.pdf")
If fileSaveName <> False Then
'active the sheet you want to print
ActiveWorkbook.Sheets(pdfName).Activate
activeSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End If
Next
End Sub
but I don't know VBA, so I don't know how to make it work for me.
Using that, it works, for one. then crashes. It does not move to the 2nd option in the drop down
Also, that requires me to press "Enter" to save. It there a way for it to save automatically so I can press run and go to lunch and have everything saved, or do I have to press Enter 300 times?
Anywhoo -- experts please help this awesome vlookuper but horrible vbaer!