Hi all,
I am trying to do something and it is probably very simple. I have been looking online for help and found a lot of interesting information but I am somehow not able to put the pieces together.
What I am trying to do:
I have a column which contains information. There are duplicates in this column.
Switch1
Switch2
Switch3
Switch2
Switch2
Switch4
Switch1
Since this column is variable in size I created a Named Range doing:
Referring to this Named Range in a Combobox on a Userform will put everything in that Combobox. The problem is that I am getting duplicate values. To get rid of the duplicate values I somewhere read I have two options:
[ol]
[li]I use an advanced filter.[/li]
[li]I go through all items in the list and put them in a variable and populate the combobox that way.[/li]
[/ol]
I am not going for option 1 since I do not want to clutter the excel sheets with data and second somehowe I just can;t get it to work. (Maybe wrong reasons but I am stuborn and want to use vba for this)
I managed to write a little function which takes the named range and can do something with it.
I call the function using:
The function I call looks like:
SO my questions are:
1. How do I create a new named range based on the new unique values?
2. WHat should I send back to the call?
I would rather have pointers or corrections than complete answers. Thanks in advance..
InDenial
I am trying to do something and it is probably very simple. I have been looking online for help and found a lot of interesting information but I am somehow not able to put the pieces together.
What I am trying to do:
I have a column which contains information. There are duplicates in this column.
Switch1
Switch2
Switch3
Switch2
Switch2
Switch4
Switch1
Since this column is variable in size I created a Named Range doing:
Code:
With Worksheets("Interfaces")
.Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row).Name = "Switches"
End With
Referring to this Named Range in a Combobox on a Userform will put everything in that Combobox. The problem is that I am getting duplicate values. To get rid of the duplicate values I somewhere read I have two options:
[ol]
[li]I use an advanced filter.[/li]
[li]I go through all items in the list and put them in a variable and populate the combobox that way.[/li]
[/ol]
I am not going for option 1 since I do not want to clutter the excel sheets with data and second somehowe I just can;t get it to work. (Maybe wrong reasons but I am stuborn and want to use vba for this)
I managed to write a little function which takes the named range and can do something with it.
I call the function using:
Code:
With CBSwitch
.ListFillRange = CreateUniqueList(Range("Switches"))
End With
The function I call looks like:
Code:
Function CreateUniqueList(Rng As Range) As Variant
Dim Element As Variant
For Each Element In Rng
MsgBox Element
Next Element
End Function
SO my questions are:
1. How do I create a new named range based on the new unique values?
2. WHat should I send back to the call?
I would rather have pointers or corrections than complete answers. Thanks in advance..
InDenial