View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
yasser yasser is offline
external usenet poster
 
Posts: 13
Default Saving a worksheet with a condition

Hi,
I have the following macro for a button that saves a file in two locations.
I want to put a condition between the code that would create a pop up message
saying that Date cell (Which is in C6) must be filled before saving the file.

My code is as follows:


Private Sub CmdSubmit_Click()

If MsgBox("Submit: '" & Sheet1.Cells(1, 1) & "?", vbYesNo Or vbQuestion _
Or vbDefaultButton2) = vbYes Then


Application.DisplayAlerts = False
ThisWorkbook.SaveAs "C:\Census\Archive\" & Sheet1.Cells(1, 1).Value &
".xls"
Application.DisplayAlerts = True

Application.DisplayAlerts = False
ThisWorkbook.SaveAs "C:\Census\Batch_Files\" & Sheet1.Cells(1, 2).Value
& ".xls"
Application.DisplayAlerts = True

MsgBox ("File Submitted Successfully")

Application.ActiveWorkbook.Close

End If

End Sub