Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.links
external usenet poster
 
Posts: 11,058
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create control button on worksheet: Forms v. ActiveX feature? [email protected] Excel Discussion (Misc queries) 2 February 16th 08 07:32 AM
How do I create a macro with a variable search feature? punkyfire Excel Discussion (Misc queries) 2 June 14th 07 07:40 PM
Excel list feature should search with more than first character DebugNT Excel Worksheet Functions 0 June 28th 06 11:26 AM
Search feature not too helpful famdamly Excel Discussion (Misc queries) 1 February 27th 06 02:03 AM
Search feature in workbook nkt122866 Excel Worksheet Functions 0 September 14th 05 10:24 PM


All times are GMT +1. The time now is 11:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"