Search field - to select best fit, from output value

LORDMARKS

New Member
Joined
Jun 5, 2014
Messages
39
Hi All

I am looking for a simple bit of code to seach column D for a name and select the next cell in column E.

The data sould be validated so there are no duplicates, but the list will end up in excess of 1000 names so I would like a button at the top to prompt for a name, then auto search/select.

The below code doesn't seem to work as It only seems to find text cells, where as my data all refs other pages to I would need to search for the output value. I have tried looking for better code, but must be missing something because they all seem to work the same way.


Thank all again for the continued help.

Code:
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]Sub search()<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]    Dim strFindName As String<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I] <o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]strFindName = InputBox("Please enter NAME", "Search...")<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I] <o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]    On Error GoTo ERRORHANDLER<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]<o:p> </o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[B][I][FONT=Verdana][SIZE=2][COLOR=red][COLOR=red][FONT=Verdana][B][I]'cant find result, as its the value of calc, not text<o:p></o:p>[/I][/B][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I][/B]
[B][I][FONT=Verdana][SIZE=2][COLOR=red][COLOR=red][FONT=Verdana][B][I]'so need to search for value of cell only<o:p></o:p>[/I][/B][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I][/B]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]<o:p> </o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]    Cells.Find(What:=strFindName, After:=ActiveCell, LookIn:=xlFormulas, LookAt _<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]        :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]        False).Select<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]        <o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[B][I][FONT=Verdana][SIZE=2][COLOR=red][COLOR=red][FONT=Verdana][B][I]'at this point I cant select the cell as it must remain locked (column D), I would like to select cell in Column E next to it<o:p></o:p>[/I][/B][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I][/B]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]        <o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]    Exit Sub<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]<o:p> </o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]ERRORHANDLER:<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]        MsgBox ("The NAME you are searching for cannot be found")<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
[I][FONT=Verdana][SIZE=2][COLOR=navy][COLOR=navy][FONT=Verdana][I]End Sub<o:p></o:p>[/I][/FONT][/COLOR][/COLOR][/SIZE][/FONT][/I]
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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