If possible, I would like to add code that would check to see if there is a file in "Return notes" that has the same text value as B1 (which contains the filename to be)
Private Sub CommandButton1_Click()
Dim NameofWorkbook As String
NameofWorkbook = "RN" & Range("B1")
MyMsg = NameofWorkbook + " " & "saved to return note folder"
'Create and assign variables
Dim saveLocation As String
saveLocation = "S:\Office information\Returns\Return Notes\" + NameofWorkbook
'Save Active Sheet(s) as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=saveLocation
MsgBox MyMsg
End Sub
Working code (Thank you Romulax):
Private Sub CommandButton1_Click()
Dim NameofWorkbook As String
Dim levSave As String
NameofWorkbook = "RN" & Trim(Range("B1"))
MyMsg = NameofWorkbook + " " & "saved to return note folder"
'Create and assign variables
Dim saveLocation As String
saveLocation = "S:\Office information\Returns\Return Notes\" & NameofWorkbook
lenSave = saveLocation & ".pdf"
If Len(Dir(lenSave)) = 0 Then
MsgBox "File does not exist"
'Do stuff
'Save Active Sheet(s) as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=saveLocation
MsgBox MyMsg
Else
MsgBox "Filename taken."
End If
End Sub