Hi guys,
I have the following code (below) which saves my active worksheet as a PDF. It works fine, however, my sheet has approximately 8000 rows, with an autofilter and the information i see on the screen is not reflected on the PDF (i.e: the info I have is 300 rows, but my PDF shows the full 215 page report - mostly consisting of blank pages...)
How can i create a PDF displaying ONLY visible rows/cells?
Thanks
This is the code:
Sub PDFActiveSheet()
Dim ws As Worksheet
Dim strPath As String
Dim myFile As Variant
Dim strFile As String
On Error GoTo errHandler
Set ws = ActiveSheet
'enter name and select folder for file
' start in current workbook folder
strFile = Replace(Replace(ws.Name, " ", ""), ".", "_") _
& "_" _
& Sheet18.Cells(14, 17) _
& ".pdf"
strFile = ThisWorkbook.Path & "\" & strFile
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile <> "False" Then
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
MsgBox "PDF created"
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "PDF not created"
Resume exitHandler
End Sub
I have the following code (below) which saves my active worksheet as a PDF. It works fine, however, my sheet has approximately 8000 rows, with an autofilter and the information i see on the screen is not reflected on the PDF (i.e: the info I have is 300 rows, but my PDF shows the full 215 page report - mostly consisting of blank pages...)
How can i create a PDF displaying ONLY visible rows/cells?
Thanks
This is the code:
Sub PDFActiveSheet()
Dim ws As Worksheet
Dim strPath As String
Dim myFile As Variant
Dim strFile As String
On Error GoTo errHandler
Set ws = ActiveSheet
'enter name and select folder for file
' start in current workbook folder
strFile = Replace(Replace(ws.Name, " ", ""), ".", "_") _
& "_" _
& Sheet18.Cells(14, 17) _
& ".pdf"
strFile = ThisWorkbook.Path & "\" & strFile
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile <> "False" Then
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
MsgBox "PDF created"
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "PDF not created"
Resume exitHandler
End Sub