I’ve deleted about 90% of the code to reduce the size of the post and because it really has little to do with the question…
Question:
I have this code attached to a button on a worksheet. Primarily, it removes the previous months data from several forms and readies them for a new month. The problem is, the button is unforgiving. Click it once and boom! Everything’s gone. Which is fine if that was the intention. I would like to know what I can add to the front of the code that will stop and say: “Are you sure?”. And then require me to click “yes” to continue or “no” to quit the code.
Sub StartNewMonth() ' ' StartNewMonth Macro ' Macro recorded 10/2/2006 by Ricky ' ' Range("C10").Select Selection.ClearContents Range("D10").Select Selection.ClearContents Range("E10").Select Selection.ClearContents ............................................................... Deleted Some Code For Brevity ................................................................... Range("C9").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("D9").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("E9").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("F9").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("G9").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("H9").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("C13").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("D13").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("E13").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("F13").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("G13").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("H13").Select ActiveCell.FormulaR1C1 = "=+R[2]C" Range("C9:H9").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("C13:H13").Select Application.CutCopyMode = False Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("C11:H11").Select Application.CutCopyMode = False Selection.ClearContents Range("C15:H15").Select Selection.ClearContents Range("C10").Select Sheets("2 - Manual Entries").Select Range("C10").Select End Sub