Hi.
I have a spreadsheet that is used as a electronic job card. After the job, it needs to be exported as a PDF and saved with the job number, quote number and order number in the file name. Example: JNo003; QNo007; ONo1234 - Todaysdate
Sometimes the quote number or the order number is not available then I want to save it without those numbers to look like this: JNo003; ONo1234 - todaysdate
The Job number is in this format: "J / No 003" for the file name to work I need to remove the " / " to look like "JNo003" in the file name
I'm newish to VBA and are stuck. Especially with the if/case part of my problem. I also have a workaround on the spreadsheet to remove the " / " by using hidden cells with formulas in there.
I'm pretty sure there are someone with more experience to assist me to do this easier and faster.
Thanks in advance.
NB: I've copied and pasted my code here. Not sure if this is the correct way.
Currently my code looks like this:
Sub SavePDF
Dim FileDir As String
Dim PDF As String
Dim QNo As String
Dim JNo As String
Dim ONo As String
JNo = Range("I18")
QNo = Range("I19")
ONo = Range("I20")
FileDir = "C:\Users" & Environ$("UserName") & "\Documents" & "Jobs"
PDF = Job_No & "; " & QNo & "; " & ONo & " - " & "E-Job Card " & _
strTime & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FileDir & PDF, OpenAfterPublish:=True
End Sub
I have a spreadsheet that is used as a electronic job card. After the job, it needs to be exported as a PDF and saved with the job number, quote number and order number in the file name. Example: JNo003; QNo007; ONo1234 - Todaysdate
Sometimes the quote number or the order number is not available then I want to save it without those numbers to look like this: JNo003; ONo1234 - todaysdate
The Job number is in this format: "J / No 003" for the file name to work I need to remove the " / " to look like "JNo003" in the file name
I'm newish to VBA and are stuck. Especially with the if/case part of my problem. I also have a workaround on the spreadsheet to remove the " / " by using hidden cells with formulas in there.
I'm pretty sure there are someone with more experience to assist me to do this easier and faster.
Thanks in advance.
NB: I've copied and pasted my code here. Not sure if this is the correct way.
Currently my code looks like this:
Sub SavePDF
Dim FileDir As String
Dim PDF As String
Dim QNo As String
Dim JNo As String
Dim ONo As String
JNo = Range("I18")
QNo = Range("I19")
ONo = Range("I20")
FileDir = "C:\Users" & Environ$("UserName") & "\Documents" & "Jobs"
PDF = Job_No & "; " & QNo & "; " & ONo & " - " & "E-Job Card " & _
strTime & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FileDir & PDF, OpenAfterPublish:=True
End Sub