-
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.
-
Jun 26th, 2019, 04:30 AM
#2
Re: VBA USERFORM : Search and Find a String and Remove from the Combobox List
Err?
If InStr(1, tecAttrVal, "- check")<=0 Then Add Else DontAdd
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
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
|