Results 1 to 20 of 20

Populating Combo Box2 based on a selection made from Combo Box1

Threaded View

newqueen Populating Combo Box2 based... 09-02-2014, 12:47 PM
jaslake Re: Populating Combo Box2... 09-02-2014, 02:10 PM
newqueen Re: Populating Combo Box2... 09-02-2014, 03:39 PM
jaslake Re: Populating Combo Box2... 09-02-2014, 03:44 PM
jaslake Re: Populating Combo Box2... 09-02-2014, 06:29 PM
mehmetcik Re: Populating Combo Box2... 09-04-2014, 08:39 PM
newqueen Re: Populating Combo Box2... 09-05-2014, 08:04 AM
newqueen Re: Populating Combo Box2... 09-06-2014, 07:34 AM
jaslake Re: Populating Combo Box2... 09-06-2014, 11:07 AM
newqueen Re: Populating Combo Box2... 09-06-2014, 05:43 PM
mehmetcik Re: Populating Combo Box2... 09-06-2014, 06:30 PM
  1. #1
    Forum Contributor
    Join Date
    05-22-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007
    Posts
    144

    Populating Combo Box2 based on a selection made from Combo Box1

    Dear all

    Please, I need a VBA code that will populate Combo Box2 based on a selection made from Combo Box1.

    I have attached a sample file.

    My Combo Boxes 1 and 2, respectively, are not on a userform. They are just on a Worksheet.

    Looking at the file attached, The Combo Boxes are on Sheet1 and the Product Listings are on a different sheet named ‘Products’ (with the main Product Categories in column G and the Categpru/Description of the products in columns A and B).

    I wish to use the setup eventually for the purposes of a quick look-up of prices of products.

    I am aware that Data Validation would work OK. However, I wish to use Combo Boxes so I’ll be able to format/manipulate the lists in each combo box, hence I need a VBA code that will drive the combo boxes.

    As I searched through forums, I came across a vba code written by royUK for a purpose that is slightly identical to mine (although used on a userform). Here is the link:

    http://www.ozgrid.com/forum/showthre...t=55961&page=2

    And here is the code:
    Option Explicit 
     
    Private Sub ComboBox1_Change() 
        Dim rng As Range 
        Dim cl As Range 
        Dim sChoice As String 
        Set rng = Range("a1", Range("a65536").End(xlUp)) 
         
        sChoice = Me.ComboBox1.Value 
        Me.ComboBox2.Clear 
        For Each cl In rng 
            If cl.Value = sChoice Then Me.ComboBox2.AddItem cl.Offset(0, 1).Text 
        Next cl 
    End Sub
    I use Excel 2007. I tried to adapt the code for my purpose. Unfortunately, I can’t get it to work for me. I should be very grateful for help with a vba code that will link the two combo boxes.

    Alternatively, if royUK’s code above could be tweaked to drive my two combo boxes on sheet 1, that will be great and I would also be grateful.

    Thanks.

    Newqueen
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Combo Box2 selections available based on Combo box 1 selection
    By wishn4fishn in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2013, 08:13 PM
  2. combo box input range based on the other combo box selection
    By hedayet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-08-2013, 02:27 AM
  3. Excel - populating data (checkboxes) based on combo box selection
    By gkang116 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-28-2011, 06:50 PM
  4. Populate a Combo Box based on the selection of another Combo Box
    By thunder279 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-18-2011, 03:40 PM
  5. [SOLVED] Select Row in List Box with 2 columns - Col 1 populates form 1 box1,Col 2 pop box2
    By bernier@lucrf.com.au in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2006, 09:10 PM

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