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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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

name1address 1postcode 1
name1address 1postcode 1
name2address 2postcode 2
name3address 3postcode 3
name4address 4postcode 4
name5address 5postcode 5
name6address 6postcode 6
name7address 7postcode 7

<colgroup><col><col><col></colgroup><tbody>
</tbody>


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,215,022
Messages
6,122,726
Members
449,093
Latest member
Mnur

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