listbox search problems

kangaruz

Board Regular
Joined
Apr 6, 2007
Messages
56
Hi Guys,
I have a userform with a multipage and 3 listboxes. with one listbox being populated with data from a sheet. When the user selects an item from the populated list box(listbox6) it will do a search of one sheet and return the value to one listbox(listbox10),and then do another search of the second sheet and return the value to the other listbox(listbox24).

My problem is i am getting duplicate results in my second listbox(listbox24) from the first sheet search. Basically i'm running two codes one after the other and return the results in two listboxes from two separate sheets.
Mark


Private Sub ListBox6_Click()
Dim r As Range, ff As String, a(), n As Long, i As Integer

With AdminNewOrder.MultiPage1.Page3
ListBox10.Clear
ListBox24.Clear
TextBox8.Value = ""
End With

If Len(Me.ListBox6.Text) = 0 Then Exit Sub
With Sheets("Orders")
Set r = .Columns("C").Find(Me.ListBox6.Text, , , xlWhole)
If r Is Nothing Then
Exit Sub
End If
ff = r.Address
Do
n = n + 1
ReDim Preserve a(1 To 6, 1 To n)
For i = 1 To 6
a(i, n) = r.Offset(, i - 3).Value
Next
Set r = .Columns("C").FindNext(r)
Loop Until ff = r.Address
End With
With Me.ListBox10
.ColumnCount = 7
.ColumnWidths = "49.95 pt;55 pt;110 pt;50 pt;50 pt;50 pt"
.Column = a
End With

With Sheets("ArchivedOrders")
Set r = .Columns("C").Find(Me.ListBox6.Text, , , xlWhole)
If r Is Nothing Then
Exit Sub
End If
ff = r.Address
Do
n = n + 1
ReDim Preserve a(1 To 6, 1 To n)
For i = 1 To 6
a(i, n) = r.Offset(, i - 3).Value
Next
Set r = .Columns("C").FindNext(r)
Loop Until ff = r.Address
End With
With Me.ListBox24
.ColumnCount = 7
.ColumnWidths = "49.95 pt;55 pt;110 pt;50 pt;50 pt;50 pt"
.Column = a
End With
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
1) Didn' I say "Wrap the code with code tag" ?
2) What do you mean by "Dups" ?

You should remember that it is only you who can see your data.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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