Filter then save to pdf

Deanandre

New Member
Joined
Jun 10, 2015
Messages
1
Hi please help. I am work on one sheet but at a specific cell I select a contractor via a number which is linked to the contractor. Then I use a filter to filter out zeros and then I save the sheet as a pdf after renaming it to the specific contractor. I have some coding already but when I want it to save to a specific folder and rename then it just wouldn't do it especially when I added more conditions. I have in total 100 contractor to choose from, filter and then save to a file as pdf and rename as well.

Sub Macro1()
'
' Macro1 Macro
'

' Select the contractor
Range("C2").Select
ActiveCell.FormulaR1C1 = "4"

' Filter the contractor to excluded zero values
ActiveSheet.Range("$A$10:$C$72").AutoFilter Field:=3, Criteria1:="<>0"

If Criteria1 Then

' Save as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("g3").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True


' If filter ends in zero then next contractor
ElseIf Criteria2 Then

Range("C2").Select
ActiveCell.FormulaR1C1 = "4"

' Filter the contractor to excluded zero values
ActiveSheet.Range("$A$10:$C$72").AutoFilter Field:=3, Criteria2:="0"


' If next contractor Zero select next contractor
Else
Range("C2").Select
ActiveCell.FormulaR1C1 = "5"

' Filter the contractor to excluded zero values
ActiveSheet.Range("$A$10:$C$72").AutoFilter Field:=3, Criteria1:="<>0"




Range("C2").Select
ActiveCell.FormulaR1C1 = "5"

' Filter the contractor to excluded zero values
ActiveSheet.Range("$A$10:$C$72").AutoFilter Field:=3, Criteria1:="<>0"

If Criteria1 Then

' Save as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("g3").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True



Range("C2").Select
ActiveCell.FormulaR1C1 = "5"

' Filter the contractor to excluded zero values
ActiveSheet.Range("$A$10:$C$72").AutoFilter Field:=3, Criteria2:="0"

'If filter ends in zero then next contractor
ElseIf Criteria2 Then


Else
Range("C2").Select
ActiveCell.FormulaR1C1 = "6"

' Filter the contractor to excluded zero values
ActiveSheet.Range("$A$10:$C$72").AutoFilter Field:=3, Criteria1:="<>0"

End If

End If





End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

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