Interupt code with message before it runs

G

Gotroots

I want to include the option to accept or cancel an action before the code
runs.

Private Sub Filldown_formula_Click()
Range("C10").Select
Selection.AutoFill Destination:=Range("C10:C7800"), Type:=xlFillDefault
Range("C10:C7800").Select
End sub


By including this msgBox which includes a “Yes†or “No†command buttons.

MsgBox "This will reset the formula, do you wish to proceed"

Thank you if you can help.
 
J

Jacob Skaria

Try the below

Private Sub Filldown_formula_Click()

If MsgBox("This will reset the formula, do you wish to proceed", _
vbYesNo + vbDefaultButton2) = vbYes Then
Range("C10").AutoFill Destination:=Range("C10:C7800"), Type:=xlFillDefault
End If

End Sub
 
J

Jacob Skaria

Copy paste the code and try

If MsgBox("This will reset the formula, do you wish to proceed", _
vbYesNo + vbDefaultButton2) = vbYes Then
Range("C10").AutoFill Destination:=Range("C10:C7800"), Type:=xlFillDefault
End If
 
G

Gotroots

I made a typo error. Sorry for the false alarm.

Jacob Skaria said:
Copy paste the code and try

If MsgBox("This will reset the formula, do you wish to proceed", _
vbYesNo + vbDefaultButton2) = vbYes Then
Range("C10").AutoFill Destination:=Range("C10:C7800"), Type:=xlFillDefault
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top