Consulting

Results 1 to 5 of 5

Thread: fill Combo box data acroding to text box data entry.

  1. #1
    VBAX Tutor
    Joined
    Sep 2009
    Posts
    231
    Location

    fill Combo box data acroding to text box data entry.

    Hi All,

    Can you please explain me how can i fill data in a combo box according to entry done in a text box.

    example i have data with several entries like:

    1201 RED 1201_RED
    1201 RED 1201_RED
    1201 BLUE 1201_BLUE
    1201 BLUE 1201_BLUE
    1202 VERT 1202_VERT
    1202 VERT 1202_VERT
    1203 yellow 1203_yellow
    1203 yellow 1203_yellow

    what i need is if i type 1201 then only :

    1201_RED
    1201_BLUE

    is display not all the colors and number.

    Am actually using this code which is adding all the colors:

    [vba]Private Sub UserForm_Initialize()


    optAddNew.Value = True
    'Me.cboPOSEdit.Enabled = False

    Me.cboPOSEdit.Enabled = True
    Dim Nullstring



    Dim sRange As Range


    Set sRange = Range("C4", Range("C65536").End(xlUp))
    FillCtrlUnique sRange, Me.cboPOSEdit
    End Sub
    Sub FillCtrlUnique(myRange As Range, myControl As Control)
    Dim Coll As New Collection
    Dim var As Variant
    Dim cell As Range

    On Error Resume Next
    For Each cell In myRange
    Coll.Add Item:=cell.Value, key:=CStr(cell.Value)
    Next cell
    On Error GoTo 0

    With myControl
    .Clear
    For Each var In Coll
    .AddItem var
    Next var
    End With
    Set Coll = Nothing
    End Sub[/vba]
    Please find also a sample of my data attached.

    Any help will be very helpful to me.
    thanking in advance.
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    [vba]
    Sub snb_002()
    mycontrol.list = Filter([transpose(if(C1:C100="","~",if(countif(offset(C1,,,row(C1:C100)),C1:C100)=1 ,C1:C100,"~")))], "~", False)
    end sub

    [/vba]

  3. #3
    VBAX Tutor
    Joined
    Sep 2009
    Posts
    231
    Location
    Hi Snb,

    many thanks for the help but i am not able to integrate the code. Can you please explain me where shall i integrate the code. is it on the text box change?

    thanks again for your help.

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Make it the userform_initialize event.

  5. #5
    VBAX Tutor
    Joined
    Sep 2009
    Posts
    231
    Location

    fill Combo box data acroding to text box data entry.

    Hi Snb,

    I have tried it but am having error like object required.

    am attaching the file.

    for your info.
    Attached Files Attached Files

Posting Permissions

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