Userform - Multiple list box searches

seanpears99

New Member
Joined
Aug 22, 2006
Messages
21
Hi everyone, been ages since I have posted on here so hopefully someone can help.

I have created a UserForm for a dependency management system and within each record I want the user to be able to use the user form to search using 7 criteria however they can use more than one criteria at once.

For example, they can search on the Unique ID only, but they can also search on Dependency Supplier Name, Supplier Program and Supplier Project. Other fields are Dependency Receiver Name, Dependency Program and Dependency Project.

I am controlling the frames on the user form to only allow the user to search on the Unique ID only, the Supplier fields only (3 of them) or the Receiver fields (3 of them). All well and good with the frames restricting the values, however do I have to coded every single permutation. i.e. If field A and Field B are not null and fields C D E F are null, search etc, and then onto the next permutation.

The single instance of code I have is (caters for 3 fields only):-

Do While x <= numEntries

If Sheets("Data").Range("F" & x).Value = Me.CBSearchSupplierName And Sheets("Data").Range("G" & x).Value = Me.CBSearchSupplierProg And Sheets("Data").Range("H" & x).Value = Me.CBSearchSupplierProj Then
isFound = True
numFound = numFound + 1
End If
x = x + 1
Loop
'Create results array
If numFound > 0 Then
ReDim Preserve rcArray(1 To numFound, 1 To 2)
Else
ReDim Preserve rcArray(1 To 1, 1 To 2)
rcArray(1, 1) = "Not Found"
End If
x = 2
Do While x <= numEntries
If Sheets("Data").Range("F" & x).Value = Me.CBSearchSupplierName And Sheets("Data").Range("G" & x).Value = Me.CBSearchSupplierProg And Sheets("Data").Range("H" & x).Value = Me.CBSearchSupplierProj Then
rcArray(lrw, 1) = Sheets("Data").Range("A" & x).Value
rcArray(lrw, 2) = Sheets("Data").Range("F" & x).Value
lrw = lrw + 1
End If
x = x + 1
Loop


Any help would be appreciated and I know my explanation is convoluted.

Sean
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,224,586
Messages
6,179,713
Members
452,939
Latest member
WCrawford

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