andrewb90
Well-known Member
- Joined
- Dec 16, 2009
- Messages
- 1,077
I have a macro with a vbYesNo in it currently, I tried adding cancel as an option (vbYesNoCancel) but ran into some issues.
Can anybody assist me in making my code run with the Cancel option?
All I need is to have the cancel option there and have the sub end if cancel is selected.
Can anybody assist me in making my code run with the Cancel option?
All I need is to have the cancel option there and have the sub end if cancel is selected.
Code:
Sub Sendit()
Dim lr As Long
' Conformation Box for Daily Sales Report Date
strPrompt = "The date for the Daily Sales Report is " & Range("B9") & " " & Range("C9") & vbNewLine & "Do you want to save with this date?"
strTitle = "Date Confirmation"
iRet = MsgBox(strPrompt, vbYesNo, strTitle)
If iRet = vbNo Then 'Date is incorrect
MsgBox ("Please type the correct date that you want to use then click on the oversized clock.")
Rows("7:85").Hidden = True
Columns("F").Hidden = True
Rows("90:91").Hidden = False
ActiveSheet.Shapes("Jumbo Clock").Visible = True
Range("A1").Select
'vbCancel????
Else 'Date is correct'
Rows("7:60").Hidden = False
Columns("F").Hidden = False
Rows("90:91").Hidden = True
ActiveSheet.Shapes("Jumbo Clock").Visible = False
MsgBox ("Saving...Please Wait...")
'This sends the info from the Midway sheet(The current numbers that are on the Daily sheet)
' to the Accounting Summary sheet. ***The Midway sheet reorganizes the info for record keeping***
lr = Sheets("Midway").Cells(Rows.Count, 7).End(xlUp).Row
Sheets("Summary").Range("c2").EntireColumn.Insert
Sheets("Midway").Range("C9:C28").Copy
Sheets("Summary").Range("C6").PasteSpecial Paste:=xlPasteValues 'The row that it starts to paste
With Sheets("Summary")
.Range("D1").EntireColumn.Copy
.Range("C1").PasteSpecial Paste:=xlPasteFormats
End With
'This clears out the Daily Sheet
Sheets("Daily").Range("D11:F40").ClearContents
Sheets("Daily").Range("F48").Select
ActiveCell.FormulaR1C1 = ""
Sheets("Daily").Range("F50:G52").ClearContents
Sheets("Daily").Range("J11:L42").ClearContents
Sheets("Daily").Range("J44:L55").ClearContents
'Sheets("Daily").Range("B49").ClearContents
Application.CutCopyMode = False
'This sets the starting amount for the deposit at $125
Range("D44").Select
ActiveCell.FormulaR1C1 = "125"
Range("E44").Select
ActiveCell.FormulaR1C1 = "125"
Range("F44").Select
ActiveCell.FormulaR1C1 = "125"
'Assigning the new Date
With Range("G90")
.Value = Date - 1
.NumberFormat = "mm/dd/yyyy"
.Offset(, -1).FormulaR1C1 = "=TEXT(RC[1],""dddd"")"
Range("B9:C9").Select
End With
'Sort sales data on the Accounting Summary sheet
Sheets("Summary").Select
Range("C7", Cells(7, Columns.Count).End(xlToLeft)).Sort _
Cells(7, 3), xlDescending, Orientation:=xlSortRows
Sheets("Daily").Select
Range("G9").Select
MsgBox ("The Daily Sales report has been archived and is now ready for use.")
End If
End Sub