Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Create a search feature in a worksheet
Hey all
This is my first post on this lovely forum i am hoping i cold get some help because i need it urgently, i have searched around incase third thread has already been posted but it has not so please help. Is it possible to create a box in Sheet1 of an Excel workbook that when you type in a word or phrase will search Sheet2 -- working just like the "find" option on the toolbar? My goal is to be able to put the word (for example) "depreciation" in a cell on sheet 1 and have it look through sheet 2 and return the general ledger accounts that have the word depreciation in them. (i.e. "depreciation exp. computers", "depreciation exp.leased equipment"). The entries on sheet 2 have account numbers in the same cell as the description. This would mimic the " find" feature, but wouldn't take me away from the page I am working on. I was trying to avoid making multiple lists and drop down menus as there are hundreds of accounts. Thankyou ever so much |
#2
Posted to microsoft.public.excel.links
|
|||
|
|||
Create a search feature in a worksheet
We will use cell A1 on Sheet1 as the data to find. Enter something in A1 and
each cell in Sheet2 will be scanned. For each match, the address of the match will be placed in column A and the match data will be placed in column B. This is a worksheet event macro: Private Sub Worksheet_Change(ByVal Target As Range) Set t = Target Set a = Range("A1") Set w = Sheets("Sheet1") If Intersect(t, a) Is Nothing Then Exit Sub Application.EnableEvents = False v = a.Value Sheets("Sheet2").Activate i = 2 For Each r In ActiveSheet.UsedRange If InStr(r.Value, v) < 0 Then w.Cells(i, 1).Value = r.Address w.Cells(i, 2).Value = r.Value i = i + 1 End If Next Application.EnableEvents = True Sheets("Sheet1").Activate End Sub Because it is worksheet code, it is very easy to install and automatic to use: 1. right-click the tab name near the bottom of the Excel window (Sheet1) 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you have any concerns, first try it on a trial worksheet. If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu2007e "Wildfire7" wrote: Hey all This is my first post on this lovely forum i am hoping i cold get some help because i need it urgently, i have searched around incase third thread has already been posted but it has not so please help. Is it possible to create a box in Sheet1 of an Excel workbook that when you type in a word or phrase will search Sheet2 -- working just like the "find" option on the toolbar? My goal is to be able to put the word (for example) "depreciation" in a cell on sheet 1 and have it look through sheet 2 and return the general ledger accounts that have the word depreciation in them. (i.e. "depreciation exp. computers", "depreciation exp.leased equipment"). The entries on sheet 2 have account numbers in the same cell as the description. This would mimic the " find" feature, but wouldn't take me away from the page I am working on. I was trying to avoid making multiple lists and drop down menus as there are hundreds of accounts. Thankyou ever so much -- Wildfire7 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to create control button on worksheet: Forms v. ActiveX feature? | Excel Discussion (Misc queries) | |||
How do I create a macro with a variable search feature? | Excel Discussion (Misc queries) | |||
Excel list feature should search with more than first character | Excel Worksheet Functions | |||
Search feature not too helpful | Excel Discussion (Misc queries) | |||
Search feature in workbook | Excel Worksheet Functions |