Q:

Excel VBA Macro Compile error: Expected End Sub

Trying to assign my code to a button which works stand-alone in VBA however but I'm receiving the following error when adding it to a button;

Compile error: Expected End Sub

My code is as follows;
Sub Button1_Click()

Private Sub filename_cellvalue()
    Dim Path As String
    Dim filename As String
    Path = Environ("userprofile") & "\Desktop\Invoices\"
    filename = Range("K13")
    ActiveSheet. ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub

VBA is new to me so any help would be greatly appreciated.  Thanks. 

A:

You're declaring a procedure twice: Sub Button1_Click()  and Sub filename_cellvalue(). 
You should delete one.  If you're putting the code in your button event, delete  Sub filename_cellvalue()

