Consulting

Results 1 to 2 of 2

Thread: UserForm within procedure - help

  1. #1
    VBAX Newbie
    Joined
    Jan 2009
    Posts
    5
    Location

    UserForm within procedure - help

    Hello -

    Trying to do something seemingly easy here.

    I have macro code within which, when the macro gets to a certain point in teh code, I want to launch a userform with 2 command buttons. Click one and the macro stops. Click the other and the macro continues.

    I have the form set up and know how to launch it. Looking for help on where/how to set up the commands to either exit the macro or continue.

    Thanks!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    'some code

    With UserForm1

    .Show
    If .Cancel Then Exit Sub
    End With

    ' more code
    [/vba]

    and in the form

    [vba]

    Option Explicit

    Private mcCancel As Boolean

    Public Property Get Cancel() As boolena
    Cancel = mcCancel
    End Property

    Private Sub cmdOK_Click()
    mcCancel = False
    Me.Hide
    End Sub

    Private Sub cmdQuit_Click()
    mcCancel = True
    Me.Hide
    End Sub

    Private Sub UserForm_Activate()
    mcCancel = False
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •