Excel: Macro to automatically print individual statements to pdf
Posted by TJ on Friday March 4, 2016 @ 04:53 PM
[Tags: Excel, tips, accounting]
[Tags: Excel, tips, accounting]
Sub printstatements()
' Print individual statements with dropdown in cell A1 and filename in A2
' by tjshome
'
'ActiveSheet.PrintOut
'With ActiveSheet
' .ExportAsFixedFormat _
' Type:=xlTypePDF, _
'
' OpenAfterPublish:=False
' dropdown
Dim strValidationRange As String
Dim rngValidation As Range
Dim rngDepartment As Range
' Turn off screen updating
'Application.ScreenUpdating = False
' Identify the source list of the data validation
' Replace cell A1 with the cell of your datavalidation dropdown with member names
strValidationRange = Range("A1").Validation.Formula1
Set rngValidation = Range(strValidationRange)
' Set the value in the selection cell to each selection in turn
' and print the results.
For Each rngDepartment In rngValidation.Cells
Range("A1").Value = rngDepartment.Value
'Call Print Macro Here
'print and format
' make sure file name and path is in cell A2 and make sure folders exists ex. c:/folder1/
Dim ThisFile As Variant
ThisFile = ActiveSheet.Range("A2").Value & ActiveSheet.Range("A1").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=ThisFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
' dropdown
Next
'Application.ScreenUpdating = True
End Sub
- Related Articles:
- Too Many Cell Formats in Excel (Resolved)
- Save Trees by changing your settings in Office and Adobe Acrobat/Reader
- Web Designers: Update your copyright years!!
Comments with offensive language will be automatically deleted within 24 hours.
