In this tutorial we are going to explain you how you show the MsgBox in Microsoft Excel using the VBA Code. The MsgBox is a dialog box in Excel VBA, you can use To inform the users of your program. Place a command button On your worksheet and add the following code lines:
- Code To show a simple message in the MsgBox:
- Code To show a little more advanced message. First, enter a number into cell A1 And Then run the below code:
- To start a new line in a message, use vbNewLine.
MsgBox "This Is fun"
Result when you click the command button On the sheet:
MsgBox "Entered value Is " & Range("A1").Value
Result when you click the command button On the sheet:
Note: we used the & operator To concatenate (join) two strings. Although Range("A1").value Is Not a string, it works here.
MsgBox "Line 1" & vbNewLine & "Line 2"
Result when you click the command button On the sheet:
No comments:
Post a Comment