Reference any value in list

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
Basically I have a list of values which I want my code to search by dependant upon which is chosen. I have this working fine, for each specific value chosen, as well as when there is no value in the searched cell. However I also to be able to look for all values but can't figure out how script this.

the code at the moment looks like this

Code:
STE = cbo1.Value
If STE = "All" Then
    SIT = Not Empty
Else
    If STE = "None" Then
        SIT = ""
    Else
        SIT = STE
    End If
End If

The not empty part does not work though.

the code later says

Code:
Do
 if rng.offset(, -19) = SIT Then
'Actions

where rng, STE & SIT are all Strings
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Okay a little bit of a change in direction. I have replaced the combobox with a listbox.

So I now want to amend the code to say

Code:
 Do
             If rng.Offset(,-19) = STE Then

where STE = all the values selected.

I'm not quite sure how to reference all the values selected though.

currently I have

Code:
Dim X As Long
    For X = 0 To listbox.ListCount - 1
    If listbox.Selected(X) = True Then
    MsgBox listbox.List(X)
    End If
    Next X

but am not sure where to go from there.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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