Calling a userform and returning a value

后端 未结 3 1894
北恋
北恋 2020-12-11 17:39

I have a vba code thats Auto_Open. It does some checks then prompts a userform that asks for username and password. I called this userform with userform_name.show

3条回答
  •  一整个雨季
    2020-12-11 18:35

    Remove Dim bool As Boolean from the userform code area and declare it in the module as shown below

    This is how your Code in the module would look like

    Public bool As Boolean
    
    Sub Auto_Open()
        '
        '~~> Rest of the code
        '
        UserForm1.Show
    
        If bool = True Then
            '~~> Do Something
        Else
            '~~> Do Something        
        End If
    
        '
        '~~> Rest of the code
        '
    End Sub
    

提交回复
热议问题