Question about msgBox

mfarres

New Member
Joined
Aug 11, 2008
Messages
4
I'm trying to create a form using msgBox function with a Yes No option. When user clicks "Yes" in the msgBox I want a certain value appear on an specific cell in the spreadsheet.

So far I got:
Select Case Response
Case Is = vbYes
then something to make the value I want appear on the cell I want
Case Is = vbNo
Nothing happens, the msgBox just closes
End Select

Can you help me to create those two actions?
Thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Here's one possibility

Sub tester()
Dim myvalue As Double 'big assumption here
myvalue = 999.99
res = MsgBox("Do you want to enter your number?", vbYesNoCancel)
If res = vbYes Then
Range("B6").Value = myvalue
End If
If res = vbNo Or res = vbCancel Then
Exit Sub
End If
End Sub
 
Upvote 0
repeating Jim's code but using your original Select Case approach:


Code:
Dim myvalue As Double  'big assumption here
myvalue = 999.99
res = MsgBox("Do you want to enter your number?", vbYesNoCancel)
'(note you could use just vbYesNo as MsgBox type)
Select Case Response
     Case vbYes
          Range("b6").Value = myvalue
     Case Else          
          Exit Sub 'if required
End Select
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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