+ Reply to Thread
Results 1 to 2 of 2

generate sub dynamically

  1. #1
    Christian Galbavy
    Guest

    generate sub dynamically

    Hello!

    I generate comboboxes dynamically in my code. Now I also want to manipulate
    the approbriate Change-functions of these elements. Is this possible and
    how?
    For example, I insert a new comobox and name it "my_box".
    Now I want to manipulate the function "my_box_Change" by my code.

    Thanks for your answers!

    Regards
    Christian Galbavy




  2. #2
    Bob Phillips
    Guest

    Re: generate sub dynamically

    Christian,

    Assuming a control toolbox combobox, here is an example of adding its click
    event

    With
    ThisWorkbook.VBProject.VBComponents(Worksheets("Sheet2").CodeName).CodeModul
    e
    .InsertLines .CreateEventProc("Click", "ComboBox1") + 1, _
    vbTab & "If Range(""A1"").Value > 0 Then " & vbCrLf & _
    vbTab & vbTab & "Msgbox ""Hi""" & vbCrLf & _
    vbTab & "End If"

    End With

    which will add this code

    Private Sub ComboBox1_Click()
    If Range("A1").Value > 0 Then
    MsgBox "Hi"
    End If

    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Christian Galbavy" <slate@sbox.tugraz.at> wrote in message
    news:%23t%23qnbkJFHA.1176@TK2MSFTNGP15.phx.gbl...
    > Hello!
    >
    > I generate comboboxes dynamically in my code. Now I also want to

    manipulate
    > the approbriate Change-functions of these elements. Is this possible and
    > how?
    > For example, I insert a new comobox and name it "my_box".
    > Now I want to manipulate the function "my_box_Change" by my code.
    >
    > Thanks for your answers!
    >
    > Regards
    > Christian Galbavy
    >
    >
    >




+ 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