"find" button

rharri1972

Board Regular
Joined
Nov 12, 2021
Messages
132
Office Version
  1. 2019
Platform
  1. Windows
Hello!
I have a userform with a listbox and a textbox with a command button.

I have been able to type the part number in the textbox and hit the "FIND" button and it would search through and highlight that part number in the list box.

Now for some reason it will search some but not all part numbers. The same part number i've been using for testing the sub's all of a sudden quit being found.

Here is the code:

VBA Code:
Private Sub CommandButton3_Click()
Dim R As Range

On Error Resume Next


  Set R = Sheets("PARTS LIST").Columns("A").Find( _
    TextBox1.Value, LookIn:=xlValues, lookat:=xlWhole)
  If R Is Nothing Then
    MsgBox "Not found"
  Else
 
  R.Parent.Select
        'Select the cell itself
    R.Select
End If

  Me.ListBox1.Value = R
     
       
   
End Sub

I don't see where anything has been changed or accidentally added or deleted. Any help?
 
yes sir! This works great. Just so I can learn...what is the difference between xl whole and xl part? It sounds like it's only check part of it rather than ALL of it(whole)
Sid....nvm I went back and saw where you already addressed the xlwhole
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
IF i can get the textbox to where I can start typing and it start to find with each character typed so that the part number ultimately "highlights" then I wont have a need for the "GO" button.

Yes that is possible. You need to use the TextBox1_Change() event instead of CommandButton3_Click(). Do the .Find inside the TextBox1_Change()
 
Upvote 0
Solution
Yes that is possible. You need to use the TextBox1_Change() event instead of CommandButton3_Click(). Do the .Find inside the TextBox1_Change()
Thank you so much Sid!!!! You've been such a great help! Your patience and willingness to teach and explain are over the top. Much appreciated!!
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

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