Macro to create Message Box in Excel


Display a Simple Message Box


Sub SimpleMessageBox()
MsgBox "Hi, Greetings from xlncad.com"
End Sub

Defining the Title of the Message Box


Sub MessageBoxTitle()
MsgBox "Hi, Greetings from xlncad.com", , "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

How to use codes shared here?