+ Reply to Thread
Results 1 to 5 of 5

Passing Procuedure to Userform

Hybrid View

  1. #1
    Nigel
    Guest

    Passing Procuedure to Userform

    I have a userform that is called from a worksheet event. On initialising I
    wish to run a procedure held in a standard module, the procedure changes
    depending on the value of the worksheet event.

    How do I pass the name of the procedure to the userform initialise event ?

    --
    Cheers
    Nigel





  2. #2
    Mike Fogleman
    Guest

    Re: Passing Procuedure to Userform

    Nigel, I am having a little problem picturing a worksheet event value. Can
    you provide the code you have and where each resides?

    Mike F
    "Nigel" <[email protected]> wrote in message
    news:[email protected]...
    >I have a userform that is called from a worksheet event. On initialising I
    > wish to run a procedure held in a standard module, the procedure changes
    > depending on the value of the worksheet event.
    >
    > How do I pass the name of the procedure to the userform initialise event ?
    >
    > --
    > Cheers
    > Nigel
    >
    >
    >
    >




  3. #3
    Norman Jones
    Guest

    Re: Passing Procuedure to Userform

    Hi Nigel,

    One way, schematically,

    Worksheet module
    '----------------------
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1")) Is Nothing Then
    If Target > 30 Then
    MyInstruction = "a"
    ElseIf Target.Value > 20 Then
    MyInstruction = "b"
    ElseIf Target.Value > 10 Then
    MyInstruction = "c"
    Else
    'Do something else
    End If
    End If
    UserForm1.Show
    End Sub
    '-----------------------------

    Userform Module
    '------------------
    Private Sub UserForm_Initialize()
    Call TestIt
    End Sub

    Standard Module
    --------------------
    Option Explicit
    Public MyInstruction As String

    '---------------------------
    Sub TestIt()
    If MyInstruction = "a" Then
    MacroA
    ElseIf MyInstruction = "b" Then
    MacroB
    Else
    'Do nothing
    End If
    End Sub

    '---------------------------
    Sub MacroA()
    MsgBox "A"
    End Sub

    '--------------------------
    Sub MacroB()
    MsgBox "B"
    End Sub

    '---------------------------
    Sub MacroC()
    MsgBox "C"
    End Sub


    ---
    Regards,
    Norman



    "Nigel" <[email protected]> wrote in message
    news:[email protected]...
    >I have a userform that is called from a worksheet event. On initialising I
    > wish to run a procedure held in a standard module, the procedure changes
    > depending on the value of the worksheet event.
    >
    > How do I pass the name of the procedure to the userform initialise event ?
    >
    > --
    > Cheers
    > Nigel
    >
    >
    >
    >




  4. #4
    Tushar Mehta
    Guest

    Re: Passing Procuedure to Userform

    In article <[email protected]>, nigel-
    [email protected] says...
    > I have a userform that is called from a worksheet event. On initialising I
    > wish to run a procedure held in a standard module, the procedure changes
    > depending on the value of the worksheet event.
    >
    > How do I pass the name of the procedure to the userform initialise event ?
    >
    >

    Check out the Application object's Run method. It accepts the name of
    the procedure to call as a string argument.

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Excel, PowerPoint, and VBA add-ins, tutorials
    Custom MS Office productivity solutions

  5. #5
    Nigel
    Guest

    Re: Passing Procuedure to Userform

    Thanks everyone that has given me some ideas.

    --
    Cheers
    Nigel



    "Tushar Mehta" <[email protected]> wrote in message
    news:[email protected]...
    > In article <[email protected]>, nigel-
    > [email protected] says...
    > > I have a userform that is called from a worksheet event. On

    initialising I
    > > wish to run a procedure held in a standard module, the procedure changes
    > > depending on the value of the worksheet event.
    > >
    > > How do I pass the name of the procedure to the userform initialise event

    ?
    > >
    > >

    > Check out the Application object's Run method. It accepts the name of
    > the procedure to call as a string argument.
    >
    > --
    > Regards,
    >
    > Tushar Mehta
    > www.tushar-mehta.com
    > Excel, PowerPoint, and VBA add-ins, tutorials
    > Custom MS Office productivity solutions




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1