Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Near the top:
Private Sub CmdSubmit_Click() if isempty(sheet99.range("C6").value) then msgbox "Please fill in that date" exit sub end if '...rest of code ==== Ps. Remember that if sheet1.cells(1,1) contains a date, you'll want to format it nicely. ThisWorkbook.SaveAs _ "C:\Census\Archive\" & format(Sheet1.Cells(1, 1).Value,"yyyymmdd") & ".xls" Since you can't have /'s in the file name (well in the wintel world). yasser wrote: 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 -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Fantastic! - It works like a charm.
"Dave Peterson" wrote: Near the top: Private Sub CmdSubmit_Click() if isempty(sheet99.range("C6").value) then msgbox "Please fill in that date" exit sub end if '...rest of code ==== Ps. Remember that if sheet1.cells(1,1) contains a date, you'll want to format it nicely. ThisWorkbook.SaveAs _ "C:\Census\Archive\" & format(Sheet1.Cells(1, 1).Value,"yyyymmdd") & ".xls" Since you can't have /'s in the file name (well in the wintel world). yasser wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
deleting rows in a worksheet if condition is met | Excel Discussion (Misc queries) | |||
Condition for worksheet reference | Excel Worksheet Functions | |||
copy row content from one worksheet to another, if a condition met | Excel Worksheet Functions | |||
copy data from 1 worksheet to another based on a condition | Excel Worksheet Functions | |||
how to hide section of worksheet based on a condition (e.g. tick . | Excel Discussion (Misc queries) |