문제

I'm very new with vba excel. I'm trying to develop little tool for report formatting tasks in vba excel. I know if i put below code into a button, it will unload my form but how can i override a msgbox's button to unload whole userform?

Unload UserForm1
도움이 되었습니까?

해결책

If I understand your question correctly (and as with Chris I'm not sure that I do), you do know that a msgbox can return a value and you can use that value to close your form? For example, the first one returns a value, the second doesn't:

Dim l As Long

l = MsgBox("What do you want to do?", vbOKCancel)

If l = vbCancel Then
     Unload UserForm1
Else
    MsgBox "You selected 'OK'"
End If

You can use the return value (l) to tell the code that called the msgbox to unload the form.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top