Macro to create Message Box in Excel

Display a Simple Message Box

Sub SimpleMessageBox()
MsgBox "Hi, Greetings from"
End Sub

Defining the Title of the Message Box

Sub MessageBoxTitle()
MsgBox "Hi, Greetings from", , "XL n CAD"
End Sub

Display a Message using a Value in an Excel Sheet

Sub DisplayValueFromSheet()
MsgBox "The value of cell A1 is " & Range("A1").Value
End Sub

Display a Message using a Text in an Excel Sheet

Sub DisplayTextFromSheet()
MsgBox "The text in the Cell C3 is " & Range("C3").Text
End Sub

Receiving two values using an Input Box and displaying their sum using Message Box

Sub SumUsingInputBox()
a = Val(InputBox("Enter the value of A"))
b = Val(InputBox("Enter the value of B"))
c = a + b
MsgBox "Sum of A and B is " & c
End Sub

Leave a Reply

Your email address will not be published.Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.