|
-
Jun 26th, 2019, 02:05 AM
#1
Thread Starter
Member
VBA USERFORM : Search and Find a String and Remove from the Combobox List
Hi Friends,
I have a combobox in User form where the data is taking from a sheet called "Inconsistency Order" and the combobox name is cmbSelChartAttr . I have so many values in the droplist. The values which ever is having a string "- check" in the end , It should not be added to the combobox List.
Example : We have values like : ABC , DEF , GHI , ABC - check , DEF , GHI - check .
So In our combobox droplist , The droplist will only show ABC , DEF , GHI .
Someone please help to add code for this in my existing Code.
Code:
Function formInitialize(ws As Worksheet)
Set ws = ThisWorkbook.Worksheets("Inconsistency Order")
If ws.Visible = True Then
ws.Activate
Else
ws.Visible = xlSheetVisible
ws.Activate
End If
Dim i, lc
Dim j
Dim cell As Range
Dim tecAttrVal As String
lc = ws.Cells(1, Columns.Count).End(xlToLeft).Column
i = 0
Dim c As Collection
Set c = New Collection
On Error Resume Next
For i = i + 1 To lc
tecAttrVal = Cells(1, i).Value
c.Add tecAttrVal, tecAttrVal
If Err.Number = 0 Then
cmbSelChartAttr.AddItem tecAttrVal
Else
Err.Clear
End If
Next i
Me.Label3.Visible = False
Me.lsbOrderSet4SelAttr.Visible = False
End Function
Thanks in Advance.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|