엑셀 VBA에서 메시지 상자
이 기사에서는 Excel VBA의 MsgBox 함수에 대해 알아 봅니다. 다음은 msgbox vba의 버튼 인수 설정입니다.
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 |
vba 메시지 상자가 사용자가 현재 워크 시트에있는 셀의 모든 내용을 삭제하는 데 어떻게 도움이되는지 살펴 보겠습니다.
다음은 데이터 스냅 샷입니다.
아래 단계를 따라야합니다 :
개발자 탭을 클릭하십시오. 코드 그룹에서 Visual Basic을 선택하십시오
-
명령 버튼을 삽입하겠습니다
-
현재 워크 시트 모듈에 다음 코드를 입력합니다 .-
명시 적 옵션
Private Sub CommandButton1_Click ()
Dim answer As Integer
answer = MsgBox ( “현재 시트의 모든 셀을 삭제 하시겠습니까?”, vbYesNo + vbQuestion, “모든 셀 삭제”)
If answer = vbYes Then
Cells.ClearContents
그렇지 않으면
‘아무것도하지 않음
End If
End Sub
-
Command 버튼을 클릭하면 다음과 같은 프롬프트가 나타납니다
-
모든 셀을 삭제하려면 예 버튼을 클릭하십시오.
-
결과는 다음과 같습니다
이런 식으로 Excel VBA에서 명령 버튼을 사용하여 모든 셀을 삭제할 수 있습니다.