Hi.
I have some code that is almost working as I want it to work.
This code will rename the PDF document with information from a couple of different cells.
for example: J1234; Q2345; O5678; 12345678; FL04 (E-Job Card 20190806-1447).pdf
The problem now is when one of or more of the cells is empty then the file name have a bunch of unwanted characters.
for example: J1234; ; ; 12345678; FL04 (E-Job Card 20190806-1447).pdf
How can I use a if statement or isblank statement to get rid of all the unwanted characters?
I have some code that is almost working as I want it to work.
Code:
Sub Job_Card_to_PDF()
Dim FileDir As String
Dim PDF As String
JNo = Range("U18").Value & "; "
QNo = Range("U19").Value & "; "
ONo = Range("U20").Value & "; "
ESN = Range("AP9").Value & "; "
Fleet = ActiveSheet.Range("AP17").Value
strTime = Format(Now(), "yyyymmdd-hhmm")
FileDir = "C:\Users\" & Environ$("UserName") & "\Documents\" & "Jobs\"
PDF = JNo & sQno & QNo & ONo & ESN & Fleet & " (E-Job Card " & strTime & ").pdf"
Application.ScreenUpdating = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FileDir & PDF, OpenAfterPublish:=True
Application.ScreenUpdating = True
End Sub
This code will rename the PDF document with information from a couple of different cells.
for example: J1234; Q2345; O5678; 12345678; FL04 (E-Job Card 20190806-1447).pdf
The problem now is when one of or more of the cells is empty then the file name have a bunch of unwanted characters.
for example: J1234; ; ; 12345678; FL04 (E-Job Card 20190806-1447).pdf
How can I use a if statement or isblank statement to get rid of all the unwanted characters?