find in entire workbook and write to userform

  • Thread starter Thread starter Legacy 361687
  • Start date Start date
  • Tags Tags
    solved
L

Legacy 361687

Guest
Hi,

I want to replicate the search function from excel, but without going to the cell location when there is a value found.

So I started making a search function myself.
It works to the point that I can find a value in a selected cell, which is pointless.

This is my code
Code:
Private Sub Searchbutton_Click()
Dim txt As String
Dim find As Range
Dim name, date, kind, ordernumber, send As String

txt = findTxt 'textbox on userform

Set find = Selection.find(What:=txt, After:=ActiveCell, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, _
            SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
 
 
If find Is Nothing Then
    MsgBox ("Nothing found")
    Exit Sub
Else
    name = name & (zoek.Offset(0, 0).Value) & vbNewLine
    date = date & (zoek.Offset(0, 2).Value) & vbNewLine
    kind = kind & vbNewLine & (zoek.Offset(0, 3).Value) & vbNewLine
    ordernumber = ordernumber & (zoek.Offset(0, 4).Value) & vbNewLine
    send = send & (zoek.Offset(0, 6).Value) & vbNewLine
End If
UserForm1.TextBox1 = name
UserForm1.TextBox2 = date
UserForm1.TextBox3 = kind
UserForm1.TextBox4 = ordernumber
UserForm1.TextBox5 = send
UserForm1.Show
Unload Me

The part that doesn't work, is where the search has to find every value occurence in al the sheets in the workbook.
I did trie, but nothing worked

could someone help me with a working example that I can modify?

Thanks in advance
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
instead of FIND, what about just filtering the data and see ONLY the found the records.
 
Upvote 0
The search function is meant to look for values without leaving the worksheet I'm curently in. If I didn't mind changing worksheets I would use the regular search function of excel
 
Upvote 0

Forum statistics

Threads
1,224,938
Messages
6,181,869
Members
453,068
Latest member
DCD1872

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