![]() |
Help with combo box
Hi
I am running a macro that looks at column "a" and populates the cells value in a combo box using additem. My problem is that if there are duplicates or blank cells i dont want them populated in the combo box. Pleae help Thanx |
Help with combo box
Hi David
Read this example for a listbox http://www.j-walk.com/ss/excel/tips/tip47.htm -- Regards Ron de Bruin http://www.rondebruin.nl "David" wrote in message k... Hi I am running a macro that looks at column "a" and populates the cells value in a combo box using additem. My problem is that if there are duplicates or blank cells i dont want them populated in the combo box. Pleae help Thanx |
Help with combo box
Try this:
Try this: 'Assuming your value to add to the combo is in cell A1 Sub Sample() 'If Cell A1 is empty, forget it. If Len(ActiveSheet.Range("A1").Value) = 0 Then Exit Sub For Each Item In ComboBox1.List 'If the value already exists, forget it.... If trim(ActiveSheet.Range("A1").Value) = trim (Item) Then i = 1 Exit For End If Next Item If i = 1 Then Exit Sub Else '....otherwise add it ComboBox1.AddItem (ActiveSheet.Range("A1").Value) End If End Sub -----Original Message----- Hi I am running a macro that looks at column "a" and populates the cells value in a combo box using additem. My problem is that if there are duplicates or blank cells i dont want them populated in the combo box. Pleae help Thanx . |
All times are GMT +1. The time now is 11:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com