For some reason I keep getting an error when I am trying to save two sheets as a PDF. Still new to VBA so i know there is a better way to do this all but this is how i have it set up right now. I always want the Letter sheet to be the first sheet in the PDF, but then I want either CAt, Dog or Bird sheet to be saved afterwards depending on which one the user picks. Right now I get an error and its not saving. I'm not sure what the reason is. I know it has to be a simple syntax error. If anyone could help me that would be wonderful.
Sub GeneratePDF()
MsgBox "start"
If Sheets("Main").Range("G17") = 1 Then
Sheets(Array("Letter", "Cat")).Select
ActiveSheet.ExportAsFixedFormat_ Type:=xlTypePDF, Filename:="D:\" & Sheets("Main").Range("B5").Value & ".pdf"
MsgBox "Saved Cat"
End If
If G18 = 2 Then
Sheets(Array("Letter", "Dog")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\" & Sheets("Main").Range("B5").Value & ".pdf"
MsgBox "Saved Dog"
End If
If G19 = 3 Then
Sheets(Array("Letter", "Bird")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\" & Sheets("Main").Range("B5").Value & ".pdf"
MsgBox "Saved Bird"
End If
End Sub
Sub GeneratePDF()
MsgBox "start"
If Sheets("Main").Range("G17") = 1 Then
Sheets(Array("Letter", "Cat")).Select
ActiveSheet.ExportAsFixedFormat_ Type:=xlTypePDF, Filename:="D:\" & Sheets("Main").Range("B5").Value & ".pdf"
MsgBox "Saved Cat"
End If
If G18 = 2 Then
Sheets(Array("Letter", "Dog")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\" & Sheets("Main").Range("B5").Value & ".pdf"
MsgBox "Saved Dog"
End If
If G19 = 3 Then
Sheets(Array("Letter", "Bird")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\" & Sheets("Main").Range("B5").Value & ".pdf"
MsgBox "Saved Bird"
End If
End Sub