ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Msg Box in IF statement? (https://www.excelbanter.com/excel-discussion-misc-queries/148214-msg-box-if-statement.html)

Elise148

Msg Box in IF statement?
 
Can I put a message box into an IF statement in VBA???

ShaneDevenshire

Msg Box in IF statement?
 
Hi,

If [A1]1 then
MsgBox "Hi"
End if

--
Cheers,
Shane Devenshire


"Elise148" wrote:

Can I put a message box into an IF statement in VBA???


Chip Pearson

Msg Box in IF statement?
 
You might try something like the following:


Dim Resp As VbMsgBoxResult
Resp = MsgBox(prompt:="Do you want to do something?", Buttons:=vbYesNo)
If Resp = vbYes Then
' code if user clicked 'Yes'
Else
' code if user clicked 'No'
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Elise148" wrote in message
...
Can I put a message box into an IF statement in VBA???




All times are GMT +1. The time now is 07:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com