Populate Combobox from Column A if Column J contains "abc"

Dluxton

New Member
Joined
May 27, 2015
Messages
3
All

I'm trying to populate a userform Combobox from a specific column in a worksheet, but only use the .additem if column 4 contains a specific text


Heading1Heading2Heading3Heading4Heading5
Value1abc
Value2
Value3abc
Value4

<tbody>
</tbody>

So Basically, i only want to show Value1 and Value 3 in my combobox options

Here's my current code. (This bit works perfect) But it's only getting a range from a single column. I'm thinking i need to extend the range to include column 4,

Private Sub UserForm_Initialize()
Dim t As Range
Dim x As Range
With Worksheets("Document Index")
lr = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For Each t In .Range("A8:A" & lr)
cmbBoxSelect.AddItem t.Value
Next t
End With
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi try:

Rich (BB code):
Private Sub UserForm_Initialize()
Dim t As Range
Dim x As Range 'Doesn't seem to be in use!
With Worksheets("Document Index")
    lr = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    For Each t In .Range("A8:A" & lr)
        If t.Offset(, 4).Value = "abc" Then
            cmbBoxSelect.AddItem t.Value
        End If
    Next t
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,438
Members
448,897
Latest member
dukenia71

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top