Consulting

Results 1 to 3 of 3

Thread: Duplicate Comboboxes

  1. #1
    VBAX Tutor Philcjr's Avatar
    Joined
    Jul 2005
    Location
    Bedminster, NJ
    Posts
    208
    Location

    Duplicate Comboboxes

    I have ten comboboxes that need to have the same value. They are named cbox_uom1, cbox_uom2, cbox_uom3...

    How can I efficiently populate the lists all at the same time?

    Here is my atempt... obviously it does not work.


    For x = 1 To 10
            With cbox_uomx
                .AddItem "BAG"
                .AddItem "BOX"
                .AddItem "DRM"
                .AddItem "EA"
                .AddItem "In"
                .AddItem "FT"
                .AddItem "GAL"
                .AddItem "LOT"
                .AddItem "PK"
                .AddItem "SET"
                .AddItem "SHT"
            End With
        Next x

    Any help would be appreciated

    Phil

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Phil

    Where are these comoboxes located?

    Are they on a userform or a worksheet?

    For a userform this might work.
    For x = 1 To 10 
    	With Me.Controls("cbox_uom" & x)
    		.AddItem "BAG" 
    		.AddItem "BOX" 
    		.AddItem "DRM" 
    		.AddItem "EA" 
    		.AddItem "In" 
    		.AddItem "FT" 
    		.AddItem "GAL" 
    		.AddItem "LOT" 
    		.AddItem "PK" 
    		.AddItem "SET" 
    		.AddItem "SHT" 
    	End With 
    Next x

  3. #3
    VBAX Tutor Philcjr's Avatar
    Joined
    Jul 2005
    Location
    Bedminster, NJ
    Posts
    208
    Location
    Norie,

    Thank you. Your code works perfectly.

    The comboboxes are all on a userform

    Thanks again
    Phil

Posting Permissions

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