1. MsgBox
엑셀 VBA에서 MsgBox 를 활용해서 사용자에게 '알림, 경고' 등의 내용을 전달할 수 있다.
2. MsgBox 함수 Syntax와 Arguments
MsgBox (prompt, [ buttons, ] [ title, ] [ helpfile, context ])
- prompt : 메세지 내용
- buttons : 버튼 종류 및 갯수(아래 세부목록 첨부)
- title : 메세지창 이름
3. 예시
사용자의 메세지 버튼 선택에 반응하게 할 수 있음
Sub MyMsgBox()
'--- Function "MsgBox" ---
'returns an Integer
'--- Reference Site ---
'https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/msgbox-function
'--- Syntax ---
'MsgBox (prompt, [ buttons, ] [ title, ] [ helpfile, context ])intReturn =
Dim intReturn As Integer
intReturn = msgbox("Contents", 0, "Titel : Titel Test")
Debug.Print intReturn
End Sub
'buttons' 에 조합 입력이 가능함
Sub MyMsgBox()
msgbox "test", 4 + 256
msgbox "test", vbYesNo + vbDefaultButton2
End Sub
다양한 버튼의 예 (buttons: #)
4. buttens arguments
Constant | Value | Description |
vbOKOnly | 0 | Display OK button only. |
vbOKCancel | 1 | Display OK and Cancel buttons. |
vbAbortRetryIgnore | 2 | Display Abort, Retry, and Ignore buttons. |
vbYesNoCancel | 3 | Display Yes, No, and Cancel buttons. |
vbYesNo | 4 | Display Yes and No buttons. |
vbRetryCancel | 5 | Display Retry and Cancel buttons. |
vbCritical | 16 | Display Critical Message icon. |
vbQuestion | 32 | Display Warning Query icon. |
vbExclamation | 48 | Display Warning Message icon. |
vbInformation | 64 | Display Information Message icon. |
vbDefaultButton1 | 0 | First button is default. |
vbDefaultButton2 | 256 | Second button is default. |
vbDefaultButton3 | 512 | Third button is default. |
vbDefaultButton4 | 768 | Fourth button is default. |
vbApplicationModal | 0 | Application modal; the user must respond to the message box before continuing work in the current application. |
vbSystemModal | 4096 | System modal; all applications are suspended until the user responds to the message box. |
vbMsgBoxHelpButton | 16384 | Adds Help button to the message box. |
vbMsgBoxSetForeground | 65536 | Specifies the message box window as the foreground window. |
vbMsgBoxRight | 524288 | Text is right-aligned. |
vbMsgBoxRtlReading | 1048576 | Specifies text should appear as right-to-left reading on Hebrew and Arabic systems. |
출처 : docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/msgbox-function
MsgBox function (Visual Basic for Applications)
MsgBox function In this article --> Displays a message in a dialog box, waits for the user to click a button, and returns an Integer indicating which button the user clicked. Note Interested in developing solutions that extend the Office experience across
docs.microsoft.com
5. 추가조사 및 보충
시간되면 다양한 예시 등등