+ Reply to Thread
Results 1 to 10 of 10

Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

Hybrid View

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    Hi.

    I have a Textbox1 and ComboBox1.
    Both are ActiveX controls.


    I need to select the name ComboBox1, retorndo is the 'Cod', in Textbox1


    The controls are on the worksheet called 'medical certificate Control 2012' and the base table is in worksheet named 'Validacao_Dinamica'
    http://www.sendspace.com/file/rl0amd
    can anyone help me?
    Cross-Post
    http://www.mrexcel.com/forum/showthr...43#post3237343
    Thank you!
    Last edited by marreco; 08-13-2012 at 07:16 PM.
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  2. #2
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    Hi.
    Any idea?

    Att

  3. #3
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    Hi.

    Any idea?

    Thank you!!

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    Hi Marreco,

    This is code for the Plan1 book - it's the only code you need there:

    Private Sub ComboBox1_Change(): Dim F As Range, P2 As Worksheet, CB As String
    Set P2 = Worksheets("Validacao_Dinamica"): Set F = P2.Range("F:F"): CB = ComboBox1
    TextBox1 = P2.Range("E" & F.Cells.Find(CB).Row)
    End Sub
    I also moved the addNmrng to the Workbook open event:

    Private Sub Workbook_Open()
    addNmRng
    End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  5. #5
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    Thanks for responding!

    I change the name in the ComboBox, but the textbox does not return anything.

    I wonder what I did wrong?

    thank you

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    Hi Marreco,

    Did you get rid of that TextBox_Change code - just use the ComboBox_Change code - it works nicely on my system?

  7. #7
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    Hi.
    That's what I'm using the module...if you can send me running the file, I'll be very grateful!
    Private Sub ComboBox1_Change(): Dim F As Range, P2 As Worksheet, CB As String
    Set P2 = Worksheets("Validacao_Dinamica"): Set F = P2.Range("F:F"): CB = ComboBox1
    TextBox1 = P2.Range("E" & F.Cells.Find(CB).Row)
    End Sub
    Sub addNmRng()
    Dim ws1 As Worksheet
    Set ws1 = Worksheets("Validacao_Dinamica")
    myRng = srtData(ws1.Range("NOME").Value)
    Worksheets("Controle atestado médico 2012").ComboBox1.List = myRng
    End Sub
    Sub clrCombox()
    'clear combobox
    Worksheets("Controle atestado médico 2012").ComboBox1.Clear
    End Sub
    Function srtData(myRng As Variant) As Variant
    Dim x As Integer, t As Integer, swp As String
        For x = 1 To UBound(myRng) - 1
            For t = x To UBound(myRng)
                If myRng(t, 1) < myRng(x, 1) Then
                    swp = myRng(x, 1)
                    myRng(x, 1) = myRng(t, 1)
                    myRng(t, 1) = swp
                End If
            Next
        Next
    srtData = myRng
    End Function
    Thank you!!

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    Hi Marreco,

    Here's the Workbook that I tested with - you'll need to fix the "Name" error but the ComboBox change now triggers the TextBox entry: Controle de atestados.xls

    Hi Marreco,

    Here's a formula that works:

    =IF(ISERROR(MATCH(A2,Validacao_Dinamica!E:E,0)),"",INDEX(Validacao_Dinamica!F:F,MATCH(A2,Validacao_Dinamica!E:E,0),1))
    Last edited by xladept; 08-13-2012 at 03:47 PM.

  9. #9
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    I'm very happy to have helped me, was excellent!

    Thank you very much!

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Select the name and ComboBox1 retornr Cod in Textbox1 (ActiveX Controls)

    You're welcome!

+ 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