With Microsoft Excel and VBA editor, you can create Sub functions. And then this article shows you the message in VBA edit with VBA code.

So I have 5 message dialog box examples to show you.

Simple Message

For a simple message dialog box, create a sub-function “SimpleMessage()” that it has “Welcome to Puthea Training” message for informing when open this Excel file. And it’s one-line statement in the dialog box.

Option Explicit
Sub SimpleMessage()

    MsgBox ("Welcome to Puthea Training")
    
End Sub

New Line Message

For a new line message dialog box, create a sub-function “NewLineMessage()” that has two line statements “Welcome to Puthea Training Channel” is the first line, and “Please help me subscribe” is the second line. They were split by constant vbNewLine.

Option Explicit
Sub NewLineMessage()

    MsgBox ("Welcome to Puthea Training Channel" & vbNewLine & "Please help me subscribe")

End Sub

Input Message

Create a sub-function “InputMessage()” that has the message “Please Give Me Your Name In Box” and Input box in the message dialog box to user input value inside and pass a value from the Input box to Cell “A1”.

Option Explicit
Sub InputMessage()

    Dim valInput As String
    valInput = InputBox("Pleae Give Me Your Name In Box")
    Range("A1").Value = valInput
  
End Sub

Yes/No Message

Create a sub-function “YesNoMessage()” and use constant “vbYesNo”. After you create this sub-function with the below code, it will pop up the decision message “Yes/No” to the user’s answer.

Option Explicit
Sub YesNoMessage()

    Dim valQ As Integer
    valQ = MsgBox("Do you want to save?", vbYesNo, "Yes or No")
    If valQ = vbYes Then
        Range("A2").Value = "You click Yes"
    Else
        Range("A2").Value = "You Click No"
    End If

End Sub

Information Message

For Information Message dialog box look like a simple message dialog box, but It has a Information icon in dialog.

Option Explicit
Private Sub btnInfo_Click()

    Dim valInfo As String
    valInfo = MsgBox("Save successfully!", vbInformation, "Information")

End Sub

Note : Information Message Type (vbMsgboxStyle) : have vbInformation, vbQuestion, vbCritical, vbExclamation, vbSystemModal

Final Result :