View Single Post
 
Old 06-10-2019, 10:49 PM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Your CommandButton1_Click sub using variables for L5 and H17
Code:
Private Sub CommandButton1_Click()
    Sheet2.CommandButton1.BackColor = RGB(242, 242, 242)
    Dim fName As Variant
    
    Dim L5part As String, H17part As String
    
    L5part = ThisWorkbook.Worksheets("Report template - Advanced").Range("L5").Value
    L5part = Replace(Replace(L5part, " / ", "/"), "/", "_")
        'MsgBox L5part      'just to see what the result is
        
    H17part = ThisWorkbook.Worksheets("Report template - Advanced").Range("H17").Value
    H17part = Replace(H17part, "/", "_")
        'MsgBox H17part      'just to see what the result is
    
    fName = Application.GetSaveAsFilename(InitialFileName:=H17part & " Report" & Range("A1").Value _
            & L5part, FileFilter:="Excel Files (*.xlsm), *.xlsm", Title:="Save As COMSEC Incident report as")
    
    If fName = False Then Exit Sub
    ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=52
End Sub
Reply With Quote