Issue with Export from Excel to PDF Macro

Slongy

New Member
Joined
Mar 15, 2013
Messages
10
Hi

I've spent a few days working on trying to establish something that should be quite simple, but anything I've found online doesn't seem to work, so I'm really hoping someone can help.

The simple requirement is this: I have an Excel file that allows pricing to be conducted via various different selections. It allows a Salesperson to produce a Quote for multiple contract types. The selections made appear in a hidden worksheet which is effectively the proposal that can be sent to the customer.
Once the pricing selections are made, a macro button allows for the proposal sheet to appear in PDF.

The issue I have, is that depending on the contract types chosen, the proposal needs to include certain content (terms and conditions and product guides).
To manage this I've created them all in the proposal with some formulas that put a zero on the row if the contract type has not been priced (and therefore the row containing the product guide is not required)
The first step of the Macro is then to filter out "0" on the column so it only contains relevant rows.. The problem I experience is that the PDF generates with blank spaces wherever the rows would have been.

I realise I've probably done this in a very clunky way, but I either need to make the macro only export visible rows to the PDF, or do something smarter. This is the Macro:

Sub Send_PDF_2()
'

'
Application.StatusBar = "Please wait while Quote is created"

Application.ScreenUpdating = True
ActiveWorkbook.Unprotect (Range("Password").Value)
Sheets("Proposal Sheet 2").Visible = True

ActiveWindow.ScrollWorkbookTabs Sheets:=1
ActiveWindow.ScrollWorkbookTabs Sheets:=1
ActiveWindow.ScrollWorkbookTabs Sheets:=1
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("Proposal Sheet 2").Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
ActiveSheet.Range("$B$1:$AY$2082").AutoFilter Field:=1, Criteria1:="="


Dim vShts As Variant
Dim strFileName As String

vShts = Sheets(1).Range("A1")
If Not IsNumeric(vShts) Then
Exit Sub
Else
strFileName = Application.GetSaveAsFilename( _
InitialFileName:="\\server\share\folder\", _
FileFilter:="PDF Files (*.pdf),*.pdf", _
Title:="Save As PDF")
If strFileName <> "False" Then
Select Case vShts
Case 1
Sheets("Proposal Sheet 2").Select
End Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=strFileName, _
OpenAfterPublish:=False
End If
End If

Sheets("Proposal Sheet 2").Visible = False
ActiveWorkbook.Protect Range("PASSWORD").Value, True, False
Sheets("Ebidd").Select
End Sub


Could someone just help me with a way of ensuring the filtered out rows, do not appear as blanks on the PDF?

Thanks in advance

Andy
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,214,940
Messages
6,122,361
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top