Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2006
    Posts
    2

    Unanswered: truncated rowsource for combobox

    Hi all,

    First post on these forums, so go easy on me.

    is there any way, when defining a rowsource for a combobox, to truncate the list that is provided?

    Essentially I have a column with only three possible types of entry and when i define the rowsource I get a list in the combobox that looks like:

    A
    A
    B
    A
    C
    C
    B
    B
    B
    C

    How do i get the combobox to just show the different entries in a list rather than ALL the entries?

    Thanks in advance

  2. #2
    Join Date
    Oct 2003
    Posts
    1,091
    Welcome to the board. Set the Row source to "unique"
    old, slow, and confused
    but at least I'm inconsistent!

    Rich
    (retired Excel 2003 user, 3/28/2008)

    How to ask a question on forums

  3. #3
    Join Date
    Jun 2006
    Posts
    103
    Here the code:

    Private Sub cmdClear_Click()
    cmbTesting.Clear
    End Sub

    Private Sub cmdLoad_Click()
    Dim rowNum As String
    Dim currentCellValue As String
    Dim foundDupFlag As Boolean

    Worksheets("Sheet1").Select
    ActiveSheet.Range("A65536").Select
    ActiveSheet.Range(Selection, Selection.End(xlUp)).Select
    rowNum = ActiveCell.Row

    'currentCellValue = ActiveSheet.Range("A1").Value
    'cmbTesting.AddItem currentCellValue
    For counter = 1 To rowNum
    'currentCellValue = ActiveSheet.Range("A1").Value
    If Not currentCellValue = ActiveSheet.Range("A" & counter).Value Then

    currentCellValue = ActiveSheet.Range("A" & counter).Value

    End If
    For innerCounter = 1 To counter - 1
    If counter = 1 Then
    foundDupFlag = False
    Exit For
    End If
    If currentCellValue = ActiveSheet.Range("A" & innerCounter).Value Then
    foundDupFlag = True
    Exit For
    End If
    foundDupFlag = False
    Next
    If Not foundDupFlag Then
    cmbTesting.AddItem currentCellValue
    End If

    Next
    End Sub

    i tried, it works, but i make 2 buttons just to test it, cmdLoad and cmdClear for loading and clearing the combo box. And data should put on column A, start from Cell A1

    Cheers

  4. #4
    Join Date
    Jun 2006
    Posts
    103
    er...by the way, i didnt c excel combo box has a property called Row Source, can tell me how to set shades, it will be great to know such a simple method from writing code, isnt it. i m not very good in excel normal function, usually what i do is using vba to code to get what i want.

  5. #5
    Join Date
    Jun 2006
    Posts
    2
    Ok, unfortunately i can't find how to set the row source to unique. Any tips?

  6. #6
    Join Date
    Jun 2006
    Posts
    103
    Hi DarkWathcer,
    Using my code to do, you dont need to set the row source to unique. Did you try? does it work?

Posting Permissions

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