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
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