Ok this is the code I have for saving from a cell that contains the file name.. everything works fine up till the point where there is nothing in the cell then it all falls apart.. My question is how do I modify it so when the cell is empty it displays a messagebox and exits the function.. Ok this is wrote as a functon because I have another sub with a VbyesNo code that runs this function upon yes.. It asks as question and depending on the answer it calls the function save2. Any ideas?
[/code]
Function Save2()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim MY_FILE As String
Const ThePath As String = "C:\Inspection Forms\"
If Dir(ThePath) = "" Then MkDir ThePath
MY_FILE = Range("E26").Value
'If MY_FILE = "" Then exit function
ActiveWorkbook.SaveAs Filename:=("C:\Inspection Forms\" & MY_FILE & ".xls"), FileFormat:=xlNormal, _
Password:="password", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
MsgBox "File " & MY_FILE & " Was saved in C:\Inspection Forms", vbInformation, "FILE HAS BEEN SAVED"
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Function
[/code]
Function Save2()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim MY_FILE As String
Const ThePath As String = "C:\Inspection Forms\"
If Dir(ThePath) = "" Then MkDir ThePath
MY_FILE = Range("E26").Value
'If MY_FILE = "" Then exit function
ActiveWorkbook.SaveAs Filename:=("C:\Inspection Forms\" & MY_FILE & ".xls"), FileFormat:=xlNormal, _
Password:="password", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
MsgBox "File " & MY_FILE & " Was saved in C:\Inspection Forms", vbInformation, "FILE HAS BEEN SAVED"
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Function
Code:
[/b]