Is it possible to modify this code to print a few pdf files for a specific list of sheets?
Sub printselection()
Dim rng As Range
Dim wks As Worksheet
Dim arr() As String
Dim i As Long: i = 0
Dim x As Integer
For x = 1 To 3
For Each rng In Sheets("Consolidated").Range(Cells(x, x), Cells(x, x))
If Trim(rng.Value) <> "" Then
On Error Resume Next
Set wks = Nothing
Set wks = Sheets(rng.Value)
On Error GoTo 0
If wks Is Nothing Then
MsgBox "Sheet " & rng.Value & " does not exist"
Else
ReDim Preserve arr(i)
arr(i) = wks.Name
i = i + 1
End If
End If
Next rng
Dim printSheets As Variant
printSheets = arr
Worksheets(printSheets).PrintOut Preview:=False, ActivePrinter:="Adobe PDF", PrintToFile:=True, PrToFileName:=PSFileName
Next x
End Sub
I am learning as I go with vba.....it works for just column A and gets hung up on the last line and was hoping it would ask for a file name as it moves to the next column X. Here is a sample of column sheet names ( I want to print each column of sheet names to a different pdf file)
A B C
CA 10 - 50 Area 1 CO 10 - 50 Area 1 GA 10 - 50 Area 1
CA 10 - 50 Area 2 CO 10 - 50 Area 2 GA 10 - 50 Area 2
CA 10 - 50 Area 3 CO 10 - 50 Area 3 GA 10 - 50 Area 3
CA 10 - 50 Area 4
CA 10 - 50 Area 5
(column A is CA, column B is CO and column C is GA)
printSheetsand run print command for each sheet inprintSheetsarray.