Hi all,
I have a macro that works in printing out the requested fields for all items on a drop down list. It determines if there is any values on the second page then prints out just one or both pages depending on what is returned. I am trying to adjust it so it saves as PDF rather than prints. When running it i get the message come up saying all files have been saved but nothing showing in the drive.
All help gratefully received.
macro is as per below and shows the all files saved message:
Sub PDF_Saving_Macro()
'
' PDF_Saving_Macro Macro
'
Dim x As Integer
x = Application.Max(Range("Z8:Z100"))
For i = 1 To x
Range("Z6").Value = i
Calculate
Dim costcentretoprint As String
costcentretoprint = Range("AA6").Value
If Range("K3").Value <> 0 Then
MsgBox (costcentretoprint & " doesn't balance - not printed")
Else
Sheets("Template").Select
Range("b1").Value = costcentretoprint
If Range("w1").Value = "N" Then
Sheets(Array("Template", "Payroll Pivot")).Select
Else
Sheets(Array("Template")).Select
End If
Sheets("Template").Activate
SelectedSheets.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="\\filepath goes here" & Range("C2").Value & ".pdf"
Sheets("Control Sheet").Select
End If
Next i
MsgBox ("Files have been saved.")
End Sub
I have a macro that works in printing out the requested fields for all items on a drop down list. It determines if there is any values on the second page then prints out just one or both pages depending on what is returned. I am trying to adjust it so it saves as PDF rather than prints. When running it i get the message come up saying all files have been saved but nothing showing in the drive.
All help gratefully received.
macro is as per below and shows the all files saved message:
Sub PDF_Saving_Macro()
'
' PDF_Saving_Macro Macro
'
Dim x As Integer
x = Application.Max(Range("Z8:Z100"))
For i = 1 To x
Range("Z6").Value = i
Calculate
Dim costcentretoprint As String
costcentretoprint = Range("AA6").Value
If Range("K3").Value <> 0 Then
MsgBox (costcentretoprint & " doesn't balance - not printed")
Else
Sheets("Template").Select
Range("b1").Value = costcentretoprint
If Range("w1").Value = "N" Then
Sheets(Array("Template", "Payroll Pivot")).Select
Else
Sheets(Array("Template")).Select
End If
Sheets("Template").Activate
SelectedSheets.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="\\filepath goes here" & Range("C2").Value & ".pdf"
Sheets("Control Sheet").Select
End If
Next i
MsgBox ("Files have been saved.")
End Sub