Creating a Search Engine in VBA for an Excel Spreadsheet

elafis

New Member
Joined
Mar 15, 2017
Messages
4
Hello all, I'm trying to update a masterfile spreadsheet which contains a whole load of employee names. In order to make it easier to navigate, I'd like to create a search bar (rather like that of google, where you type in the text box, click search, and it takes you to what you queried).

I've searched and searched but can't find anything that fits my exact spreadsheet, hence me asking here! I'm quite inexperienced with VBA coding but I get the basics as I did some work with C++ a few years back (I know it's different but, yeah, ya know).

My issue is, I have the names in rows, not columns, with the header as names, for instance, instead of having the title "Names" in A1, and then the names being displayed below the title vertically (B1, B2....), the title "Names" is in A1, and then the employee names are displayed horizontally (ie A2, A3....) I cannot change the way this is laid out as it's very specific to the work I'm doing.

I want to create a search bar, preferably in the employee sheet (called Upload Template) where you type in an employee name, for instance "John", and when you click the "Search" button, it takes you to the cell with the employee called John in it and the information relating to that employee, I'd like the search engine to search up anything with the name "John" for instance, if you just typed in "Jo" it would return any name with "Jo" in it (like using the * function in Excel).

Sorry if I'm being vague, if I've left anything out that could help please let me know! Thanks in advance
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I know about this, but I'm wanting an actual search bar as I'm not the only one using it! Thank you :)
 
Upvote 0
I`d create a macro, running after you edit a textbox field:
1. hide all rows of data
2. unhide rows, where instr(range("a1"),textbox.text)>0
 
Upvote 0
i would probably go for freezing row 1 and creating a vlookup based on name put in A1 so it returns the row of that name to the top row

edit example

[TABLE="width: 332"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]name1[/TD]
[TD]address 1[/TD]
[TD]postcode 1[/TD]
[/TR]
[TR]
[TD]name1[/TD]
[TD]address 1[/TD]
[TD]postcode 1[/TD]
[/TR]
[TR]
[TD]name2[/TD]
[TD]address 2[/TD]
[TD]postcode 2[/TD]
[/TR]
[TR]
[TD]name3[/TD]
[TD]address 3[/TD]
[TD]postcode 3[/TD]
[/TR]
[TR]
[TD]name4[/TD]
[TD]address 4[/TD]
[TD]postcode 4[/TD]
[/TR]
[TR]
[TD]name5[/TD]
[TD]address 5[/TD]
[TD]postcode 5[/TD]
[/TR]
[TR]
[TD]name6[/TD]
[TD]address 6[/TD]
[TD]postcode 6[/TD]
[/TR]
[TR]
[TD]name7[/TD]
[TD]address 7[/TD]
[TD]postcode 7[/TD]
[/TR]
</tbody>[/TABLE]


formula in b2 dragged across for as many columns needed

Code:
=VLOOKUP($A$1,$A:$C,COLUMN())
 
Last edited:
Upvote 0
Hi akatrouble, surely this just returns the names in the columns, rather than rows (which I need)?
Appreciate the help!
 
Upvote 0
if you have 10 columns one of which is Name it will return the contents of those ten columns from the row where name matches. if 20 columns drag the formula as far as needed

my example above i typed name1 in A1 and the other info was returned by the formula


if not what you are looking for then apart from userform or macro i can't think of a way sorry
 
Upvote 0
Unfortunately that's not exactly what I'm looking for, I was thinking more of some sort of VBA code, but I greatly appreciate your feedback! :D
 
Upvote 0

Forum statistics

Threads
1,223,276
Messages
6,171,139
Members
452,381
Latest member
Nova88

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