-
Guys people in mrexcel.com already posted solution, i paste it here for purpose of education and solve problem for others, just move table on B9, and code work.
Public Sub Save_Sheets_As_PDF()
Dim DesktopFolder As String
Dim PDFfile As String
Dim cell As Range
Dim replaceSelected As Boolean
Dim currentSheet As Worksheet
DesktopFolder = CreateObject("WScript.Shell").SpecialFolders("Desktop") & ""
Set currentSheet = ActiveSheet
replaceSelected = True
With ThisWorkbook
PDFfile = DesktopFolder & .Worksheets("Input").Range("C17").Value
For Each cell In .Worksheets("Input").Range("B10:B13")
If cell.Offset(, 1).Value > 0 Then
.Worksheets(cell.Value).Select Replace:=replaceSelected
replaceSelected = False
End If
Next
End With
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFfile, OpenAfterPublish:=False, IgnorePrintAreas:=False
currentSheet.Select
End Sub
II Second solution:
Sub ExportPdf()
Dim hojas() As String, dFolder As String
Dim i As Long, n As Long
dFolder = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator
With Sheets("Input")
For i = 10 To 13
If .Range("C" & i) > 0 Then
ReDim Preserve hojas(n)
hojas(n) = Sheets(.Range("B" & i).Value).Name
n = n + 1
End If
Next
If n > 0 Then
Sheets(hojas).Select
ActiveSheet.ExportAsFixedFormat xlTypePDF, dFolder & .[C17] & ".pdf", 0, True, False, , , False
.Select
End If
End With
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules