Search code help needed

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
I have this piece of code that allows a customer record to be searched via surname and then it displays the name in a textbox. so if the customers name was John Smith I need to type in Smith and click the find button on the useform and it will display it as Smith John, the search bit is fine and I have no issue with the name being back to front.

I want the range to include more information, currently the surname is in column 2 and the info for column 2 + 3 are only displayed. I want the info for column 1 to 9 to be displayed in the textbox.

Private Sub cmdFind_Click()
Dim SearchItem As String
Dim Error

If (tbFindLastName.Text = Empty) Or (tbFindLastName.Text = " ") Then
Error = MsgBox("I have nothing to search for!", vbExclamation, "Search Error!")
Else
SearchItem = tbFindLastName.Text
tbFindLastName.Text = Empty
SelectItem (SearchItem)
End If
End Sub
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi

i'm still stuck on this can anyone help o_O:oops:
 
Upvote 0

Forum statistics

Threads
1,215,347
Messages
6,124,421
Members
449,157
Latest member
mytux

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