troglodyte
New Member
- Joined
- Sep 9, 2014
- Messages
- 11
Code:
Sub PDFCreator()
'
' PDF Creator Macro
'This should create an individual PDF for each variable and save it in the correct location
'
'
'Define the save location
'
Dim FName As String
Dim FPath As String
Dim rng As Range, cell As Range
FPath = "Q:\Files\
FName = Sheets("Core Data").Range("D4").Text
'
'Selects the list of variables in these cells
'
Set rng = Range("A2:A40")
For Each cell In rng
Range("A2").Select
Selection.Copy
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Summary page").Select
Application.CutCopyMode = False
'
'Input a timer delay here as the file is quite large and needs time to refresh for a new input
'
Application.Wait (Now + TimeValue("0:00:15"))
ThisWorkbook.SaveAs filename:=FPath & "\" & FName.pdf
Next cell
End Sub
The above VBA (I hope) will cycle through a list of variables in a range (A2:A40) and for each variable in that range the code will save a PDF version of the "Summary Page" in the specified location. I'm still learning VBA and the above is throwing a Compile error at me, I'm not too sure why? I would be grateful for any pointers here!
Thank you.