+ Reply to Thread
Results 1 to 2 of 2

Combo box help

  1. #1
    Registered User
    Join Date
    MS-Off Ver
    Excel 2010

    Combo box help


    i am a newbie in Macro, i need help to create a combo box from excel which is link from another data sheet, that everytime i choose one data in on combo box the values will show to another combo box.

    this is my Data Sheet
    Date Month
    1 January
    2 February
    3 March
    4 April
    5 May
    6 June
    7 July
    8 August
    9 September
    10 October
    11 November
    12 December

    this is my validation sheet.
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 this is my validation data in Date
    =OFFSET(Header,MATCH($C$4,Date,0),0,COUNTIF(Date,$C$4),1) this is in Month

    Date Month
    2 February

    i wanted to use the combo box because i have a big data file, i think it is better to use so i can type directly and combo box can auto type or something..

    please help... thank you in advance.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    MS-Off Ver
    Excel 2010

    Re: Combo box help

    Try this it currently works in Excel 2010 Keep in mind I am using a User Form not an active x control within the spread sheet.

    This will load your first combo box with a list

    Code[Private Sub cb_scentsy_invntry_Load()
    Dim i As Long, j As Long
    Dim colList As Collection
    Dim Lastrow As String

    Lastrow = Worksheets("sheetNAMEhere").Cells(Rows.Count, 1).End(xlUp).Row

    Set colList = New Collection

    With Worksheets("sheetNAMEhere")
    For i = 2 To Lastrow
    On Error Resume Next
    colList.Add .Cells(i, 1).Value, CStr(.Cells(i, 1))
    Next i

    For j = 1 To colList.Count
    Me.cb_scentsy_invntry.AddItem colList(j)
    Next j
    End With
    End Sub

    Private Sub cb_scentsy_invntry_Change()
    Dim Lastrow As Integer
    Dim x As Long
    Dim myVal As String

    myVal = me.Combo Box1 Name.Value

    'loop through Column B
    Lastrow = ThisWorkbook.Sheets("SheetNAMEhere").Cells(Rows.Count, 1).End(xlUp).Row

    'clear combobox

    'adds all parts related to the choice in Combobox1
    For x = 2 To Lastrow
    If myVal = ThisWorkbook.Sheets("SheetNameHere").Cells(x, 1) Then
    Me.cb_prdt_nme.AddItem ThisWorkbook.Sheets("SheetNAMEhere").Cells(x, 2)
    End If
    Next x

    End Sub]Code

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 8
    Last Post: 12-26-2013, 02:23 PM
  2. [SOLVED] Excel 2010 VBA – Combo Box Options– Clear cell/box in 2nd Combo when 1st Combo selected
    By theshybutterfly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2013, 07:25 PM
  3. [SOLVED] How to reference a second Combo box’s output based on previous Combo Box’s Row source
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2012, 11:27 AM
  4. Filtered list for Combo Box ListFillRange - Nested Combo Boxes
    By DoctorG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-23-2006, 08:20 AM
  5. Replies: 0
    Last Post: 02-15-2005, 06:45 PM

Tags for this Thread


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