If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > truncated rowsource for combobox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-06, 08:45
DarkWathcer DarkWathcer is offline
Registered User
 
Join Date: Jun 2006
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 06-08-06, 11:02
shades shades is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 06-09-06, 00:05
mkggoh mkggoh is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 06-09-06, 00:08
mkggoh mkggoh is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 06-09-06, 04:48
DarkWathcer DarkWathcer is offline
Registered User
 
Join Date: Jun 2006
Posts: 2
Ok, unfortunately i can't find how to set the row source to unique. Any tips?
Reply With Quote
  #6 (permalink)  
Old 06-09-06, 05:41
mkggoh mkggoh is offline
Registered User
 
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On