I am having issues with adding a VBA code to a command button.
I am attempting to create an excel training sign off that saves a worksheet as a PDF to a particular folder and also names it using information in certain cells.
The code I am using is:
Private Sub CommandButton1_Click()
Sub SaveAsPDF()
EmployeeID = Range("F39")
EmployeeName = Range("F41")
Path = "H:\LRT\LRT - Training Division Staff - Light Rail\LRT - Training Division - Systems RSF\Trk\Track Training\Sign Offs"
fname = EmployeeID & "-" & EmployeeName
MsgBox "Saved as PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, ignoreprintareas:=False, Filename:=Path & fname
End Sub
It works when I run the code without the Private Sub , but as soon as I add it I get an error stating "Compile Error: Expected End Sub".
I have attached a screenshot of the error message.
I am one level up from being a novice and can usually work these things out, but I am stumped with this one.
Bookmarks