Following advice from this forum I have developed the following code to save a workbook with a filename made up from Ranges within a worksheet. What I had also hoped to do was include the first 2 letters of a Range.
The code that works is as follows
Private Sub SaveFile_Click()
'
' SaveFile Macro
'
Dim Dt As Date
Dim Ex As String
Dt = Range("StartDate").Value
Ex = Left(ExIncOp, 2)
'
If IsEmpty(Worksheets("Operation").Range("ExIncOp")) Then
Msg = MsgBox("Please enter TYPE in cell C6 to continue ", vbOKOnly)
End If
If IsEmpty(Worksheets("Operation").Range("Name")) Then
Msg = MsgBox("Please enter NAME in cell H6 to continue ", vbOKOnly)
End If
If IsEmpty(Worksheets("Operation").Range("StartDate")) Then
Msg = MsgBox("Please enter DATE FROM in cell E10 to continue", vbOKOnly)
Exit Sub
End If
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & _
Range(Debrief_Folder) & "\" & Range("Name").Value & " " & Format _
(Dt, "dd-mmm-yy") & ".xls", FileFormat:=xlNormal
End Sub
This code includes the line
which I believe creates a variable Ex made up of the first 2 characters of the Range ExIncOp.
How do I then introduce this variable into the ActiveWorkbook line?
I have tried
but I realise Ex is not a Range so this fails.
Bookmarks