Vba: adding a message box

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
831
Office Version
  1. 365
Platform
  1. Windows
I am showing below a small sample of my code. I am wanting a yes no message box to popup before the rest of the code runs. If yes then code runs if no it cancels out the macro at this time. Im not sure how to add it. Thanks

Sub STOCK_FORM_SEND()

'
'
ActiveSheet.Unprotect
Dim ButtonName As Variant
Dim ButtonNames As Variant

' Change/add button names accordingly
ButtonNames = Array("Button 7", "Button 8", "Button 2")

For Each ButtonName In ButtonNames
ActiveSheet.Buttons(ButtonName).Visible = False
Next ButtonName

Range("H24").Select
Selection.Interior.ColorIndex = 6
ActiveCell.FormulaR1C1 = "OPERATOR CHECKED"
With ActiveCell.Characters(Start:=1, Length:=14).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 18
.Strikethrough = False
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try

Code:
If MsgBox("Run the code", vbQuestion + vbYesNo) = vbNo Then Exit Sub
 
Upvote 0
Thanks VOG, is there away to change "Microsoft Excel" thats in the left corner to text I need
 
Upvote 0
Try like this

Code:
If MsgBox("Run the code", vbQuestion + vbYesNo, "Your title here") = vbNo Then Exit Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top