Is there a way to create a userform that does the same thing as the Find Userform

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I would like to create a similar userform like the Find function (ctrl+F) but I need it to "Find All" the cells that contain the value of a text box then display them in a listbox like the Find All button within the find function. Once all the cells are found, I would need to loop through each location found in the list and offset it to retrieve another value. So I know how to find values by using the .find but how can I display them in a list box and loop through the list to obtain the values needed.

Thank You
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Something like
Code:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
   Dim Ary As Variant
   Dim Cnt As Long, i As Long
   Dim Cl As Range
   
   If Me.TextBox1 = "" Then Cancel = True: Exit Sub
   Cnt = Application.CountIf(Range("A:A"), Me.TextBox1.Value)
   If Cnt = 0 Then
      Me.TextBox1 = ""
      Cancel = True
      Exit Sub
   End If
   Set Cl = Range("A1")
   ReDim Ary(1 To Cnt, 1 To 2)
   For i = 1 To Cnt
      Set Cl = Range("A:A").Find(Me.TextBox1.Value, Cl, , xlWhole, , xlNext, False, , False)
      Ary(i, 1) = Cl.Address: Ary(i, 2) = Cl.Offset(, 2).Value
   Next i
   Me.ListBox1.list = Ary
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

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