ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populate form combo with unique values (https://www.excelbanter.com/excel-programming/371322-populate-form-combo-unique-values.html)

Piers 2k

Populate form combo with unique values
 
Hi folks,

Simple list spreadsheet, column headings, etc... Have a combo on a form I'd
like to populate with unique values from a column in the range.
Current code works fine (obviously selecting cells first), but no way to
only show unique values? Any idea how can I eliminate them?

' start of code
Dim item As Range

For Each item In Selection
cmbDept.AddItem item
Next
' end of code

Any ideas?

TIA,
Piers



bigwheel

Populate form combo with unique values
 
Well, you could build the Advanced Filter into your code which does allow you
to see unique values then those values would be used to populate your combo

Range(whatever).AdvancedFilter Action:=xlFilterInPlace, Unique:=True

"Piers 2k" wrote:

Hi folks,

Simple list spreadsheet, column headings, etc... Have a combo on a form I'd
like to populate with unique values from a column in the range.
Current code works fine (obviously selecting cells first), but no way to
only show unique values? Any idea how can I eliminate them?

' start of code
Dim item As Range

For Each item In Selection
cmbDept.AddItem item
Next
' end of code

Any ideas?

TIA,
Piers





All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com