Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    COMBOBOX and tootip in excel userform (2000)

    I have in column A form A2:

    133345
    989898
    231215

    in column B from B2

    aaaa
    bbbb
    ccccc

    i want to fill a combobox with value in column A, and when i pick a item in combobox show the tooltip with correspondence of same line in sheet...
    Example:

    i pick the item 133345 show tooltip aaaa
    i pick the item 989898 show tooltip bbbb
    ecc...

    similar a mouse over on items....
    possible with vba for excel?
    tks

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: COMBOBOX and tootip in excel userform (2000)

    Presume that the combobx is named ComboBox1 and the range is A1:A20 and B1: B20 (adjust as appropriate)

    In the properties of ComboBox set the row source to A1:A20. Then add the code to the userform code:

    <pre>Private Sub ComboBox1_Change()
    If Me.ComboBox1.ListIndex >= 0 Then
    Me.ComboBox1.ControlTipText = _
    Range("B1:B20").Cells(Me.ComboBox1.ListIndex + 1)
    End If
    End Sub</pre>


    This will change the ControlTip after each change of the combox to be the appropriate value in column B.

    Steve

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: COMBOBOX and tootip in excel userform (2000)

    Hi Steve...
    See wath i have found!
    Is perfect for my prob, but sure not have knoledgment to modify the code.
    Attached sheet with data to fill combo and value to show controltiptext...
    The column in the sheet cartel2 are AA and AB

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: COMBOBOX and tootip in excel userform (2000)

    Make these 3 changes to the code:

    1) Modify the userform initialize to read into the combobox the range in AA (added 2 new variables and some lines, deleted some of their for loop...)

    <pre>Private Sub UserForm_Initialize()
    'http://www.mrexcel.com/forum/showthread.php?t=295844
    Dim rCell As Range
    Dim rAA As Range
    Dim i As Byte
    'poulate cmb and assign it to a global var
    Set rAA = Range(Range("AA2"), _
    Cells(Cells.Rows.Count, "AA").End(xlUp))
    With ComboBox1
    For Each rCell In rAA
    .AddItem rCell.Value
    Next
    .ListIndex = 0
    End With
    Set oCmb = Me.ComboBox1

    Call CreateStaticCtl
    Call SubClassStaticCtl
    Set rCell = Nothing
    Set rAA = Nothing
    End Sub</pre>


    2) In the Mouse Move delete all the "sMessageString" Lines. The last lines of the code should be:

    <pre> With GetCursorPosition
    Call SetStaticPos(hWndStatic, .x, .y)
    End With

    Call ShowText(lRow)

    End Sub</pre>


    3) Change the sMessageString Line in the "ShowText" routine to read from AB:
    <pre>]Private Sub ShowText(ByVal row As Byte)
    sMessageString = Cells(row + 2, "AB").Value
    End Sub</pre>



    Steve

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: COMBOBOX and tootip in excel userform (2000)

    EXCELLENT!
    tKS.

Posting Permissions

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