Hi Guys
I need a little help please, I have the following code:
Code
Sub Save()
'Loop Through Saved Files and Create New Report
Dim SvPath
SvPath = "C:\Users\Owner\Dropbox\Accounts Miqlat\Reports\"
Dim Ctr
Dim Mth
Mth = Sheets("Centre").Range("I1")
Sheets("Centre").Activate
'Sheets("Centre").Range("D1").Value = "Admin"
Dim c As Range
Dim i As Long
Dim inputrg As Range
Ctr = Sheets("Centre").Range("D1")
Set inputrg = [Centre] 'Look at Range [Centre] for value
Dim FileN As String
Dim NewFile As String
i = 1
For Each c In inputrg
'Ctr.Value = c.Value 'Loop through
Sheets("Centre").Range("D1").Value = c.Value
FileN = c & " - " & Mth 'FileName
If Dir(SvPath & FileN & ".pdf") <> "" Then
Do
n = n + 1
NewFile = FileN & " (v" & n & ")" 'New File if Exists
Loop Until NewFile <> ""
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=SvPath & NewFile
Else
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=SvPath & c & " - " & Mth & ".pdf"
End If
i = i + 1
n = 0
Next c
Sheets("Consolidated").Activate
Dim ConsFileN As String
Dim ConsNewFile
ConsFileN = "Consolidated" & " - " & Mth
If Dir(SvPath & ConsFileN & ".pdf") <> "" Then
'MsgBox "File Exist"
Do
n = n + 1
ConsNewFile = ConsFileN & " (v" & n & ")"
Loop Until ConsNewFile <> ""
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=SvPath & ConsNewFile
Else
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=SvPath & "Consolidated" & " - " & Mth & ".pdf"
End If
n = 0
End Sub
Display More
This works fine, except ideally I would like to save all the files into one PDF document with the name being Mth (eg Jan-18)
I guess something like copy values to a new sheets each time and then some kind of array for those new sheets.
There will only ever be 4 sheets in the array.
Thanks