VB search for a string and return the row the string is found in list box

Otter850

New Member
Joined
May 25, 2011
Messages
1
I am working on a userform that will allow a user to enter a number, that number is then searched for on a worksheet. If the number is found, I want to return the entire row of data that contains the number. (for ease of use the searched for number will be in column A) I would like to have the user see the return data in the userform as label captions but a single list box would be fine. Below is my code:

Code:
 private sub command button1_click

Dim FndStr As String
Dim FndVal As Range
Dim as As Worksheet
FndStr = Me.txtNum (textbox)
Set ws = Worksheets ("Tracking")
Set FndVal = Worksheets("Tracking").Range("A3:A3089").Find(What:=FndStr, LookAt:=xlWhole)

If FndVal Is Nothing Then
   MsgBox "Number not found"
Else
MsgBox "Number found"

[\code]
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

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