I have a repeatable error, but I'm not sure how to account for it. I'm formulating a filename based on the contents of a few different cells. If one of the cells is blank I want it to be left out of the mix. Here is the code:
ElseIf SaveChk = 1 Then
Module1.UserPath = Environ("USERPROFILE")
Module1.Path = UserPath & "\Desktop\"
If IsEmpty(Range("Y59")) Then
Module1.SaveName = Range("AE6").Value & " " & Range("E6").Value
Else
Module1.SaveName = Range("AE6").Value & " " & Range("E6").Value & " - " & Range("Y59").Value
End If
Application.EnableEvents = False
Range("AE59") = Format(Now, "mm-dd-yyyy hh:mm:ss AM/PM")
Application.EnableEvents = True
Call HideSheets
Application.DisplayAlerts = False
ThisWorkbook.SaveAs _
Filename:=Path & SaveName & ".xlsm", _
FileFormat:=52
Application.DisplayAlerts = True
MsgBox "Filename = " & SaveName & vbNewLine & "File is saved to your desktop."
Else
MsgBox "Please Completed Shaded Cells!", vbOK + vbExclamation, "SAVE CANCELLED"
End If
End If
Module1.SaveChk = 0 'Reset SaveChk variable
Module1.BttnChk = 0 'Reset BttnChk variable
Call UnhideSheets
Call Prot
Exit Sub
EH:
Call ErHa
Resume Next
End Sub
The code works fine. However, I get an error when Y59 is in the middle of being edited. What I mean is, if a user types in a number in Y59 and then clicks on my custom save button instead of completing the cell edit, my save message shown above is displayed but then an error is thrown. Stepping through the code, the error occurs on the "Exit sub" line of my Save Form sub (which is the one shown above). I'm trying to account for this usage case, thoughts?
As my last comment indicated, the issue involved the "Sheet Change" worksheet sub which I was using to capture paste commands and convert them to paste special value commands.
So, that sub conflicted with the various subs used to validate saving on my worksheet.
I'll have to rework the subs to remove the error or just let it go because the error isn't actually doing anything.