Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Natalie
 
Posts: n/a
Default Find function in a macro

Hi,

Is there any way that I can create a "find" button on my excel spreadsheet?

I have a lot of data for people that aren't familar with excel and I thought
adding a button with a macro on the actual worksheet would make it easier?
  #2   Report Post  
Harald Staff
 
Posts: n/a
Default

Sure. How would you like it to behave ? Where shall the user enter her
search criteria ? How should the button respond to it ?

HTH. best wishes Harald

"Natalie" skrev i melding
...
Hi,

Is there any way that I can create a "find" button on my excel

spreadsheet?

I have a lot of data for people that aren't familar with excel and I

thought
adding a button with a macro on the actual worksheet would make it easier?



  #3   Report Post  
Natalie
 
Posts: n/a
Default

Ideally I would like -

Cell A1 - Type in search critieria
Cell B1 - Search button to click after typing in criteria

Then

Any name matching the criteria to appear in the rows below?

Thanks!

"Harald Staff" wrote:

Sure. How would you like it to behave ? Where shall the user enter her
search criteria ? How should the button respond to it ?

HTH. best wishes Harald

"Natalie" skrev i melding
...
Hi,

Is there any way that I can create a "find" button on my excel

spreadsheet?

I have a lot of data for people that aren't familar with excel and I

thought
adding a button with a macro on the actual worksheet would make it easier?




  #4   Report Post  
Myrna Larson
 
Posts: n/a
Default

What is already in the rows below 1? If it's your list, you don't want to copy
the found data over the existing data, do you? Where is the data that you want
to search?


On Tue, 22 Mar 2005 07:11:10 -0800, "Natalie"
wrote:

Ideally I would like -

Cell A1 - Type in search critieria
Cell B1 - Search button to click after typing in criteria

Then

Any name matching the criteria to appear in the rows below?

Thanks!

"Harald Staff" wrote:

Sure. How would you like it to behave ? Where shall the user enter her
search criteria ? How should the button respond to it ?

HTH. best wishes Harald

"Natalie" skrev i melding
...
Hi,

Is there any way that I can create a "find" button on my excel

spreadsheet?

I have a lot of data for people that aren't familar with excel and I

thought
adding a button with a macro on the actual worksheet would make it

easier?




  #5   Report Post  
Harald Staff
 
Posts: n/a
Default

Ok, one approach:

Open the excel file in question.
Open the VB editor (Alt F11 or similar).
There, menu Insert Module.
You will see a new blank module sheet. Paste this into it:

' ****** beginning of block *****
Option Explicit

Sub ButtonClick()
Dim S As String
Dim R1 As Range, R As Range
Dim Cbo As DropDown

S = ActiveSheet.Range("A1").Value
If S = "" Then Exit Sub
Set Cbo = ActiveSheet.DropDowns(1)
Cbo.RemoveAllItems
On Error Resume Next
Set R = Cells.Find(What:=S, _
After:=Range("A1"), _
LookAt:=xlWhole)

If R Is Nothing Then Exit Sub

Cbo.AddItem R.Address(False, False)

Do
Set R = Cells.Find(What:=S, _
After:=R, _
LookAt:=xlWhole)
Cbo.AddItem R.Address(False, False)
Loop Until R.Address = "$A$1"

Set Cbo = Nothing
End Sub

Sub CboSelect()
Dim Cbo As DropDown
Set Cbo = ActiveSheet.DropDowns(1)
ActiveCell.Activate
Range(Cbo.List(Cbo.ListIndex)).Select
Set Cbo = Nothing
End Sub
' ****** end of block *****

Now return to Excel and your sheet.
Go menu View Toolbars, select the Forms Toolbar.
There is a button on it. Place a button over cell B1.

Assign the "ButtonClick" macro to it if asked. If not then do it manually by
rightclicking it and choose "assign macro"

There is also a ComboBox on it. Place it below the button. Assign the
"CboSelect" macro to it if asked. If not then do it manually by
rightclicking it and choose "assign macro".

And that's it. Enter something in A1, click the button and matching cells
are listed in the combobox. Select a cell address in the combobox and you're
transported to it on a magic carpet.

Change the text xlWhole to xlPart in the macro code if you want to search
for part of the cell content instead of whole cells.

HTH. Best wishes Harald

"Natalie" skrev i melding
...
Ideally I would like -

Cell A1 - Type in search critieria
Cell B1 - Search button to click after typing in criteria

Then

Any name matching the criteria to appear in the rows below?

Thanks!

"Harald Staff" wrote:

Sure. How would you like it to behave ? Where shall the user enter her
search criteria ? How should the button respond to it ?

HTH. best wishes Harald

"Natalie" skrev i melding
...
Hi,

Is there any way that I can create a "find" button on my excel

spreadsheet?

I have a lot of data for people that aren't familar with excel and I

thought
adding a button with a macro on the actual worksheet would make it

easier?







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
What function would let me find Batting Averages? pertimesco Excel Worksheet Functions 0 March 1st 05 10:21 AM
PivotTable Macro Reverts to Count Function LTofsrud Excel Worksheet Functions 4 February 8th 05 09:41 PM
macro to Find Replace in Excel Nurddin Excel Discussion (Misc queries) 7 January 3rd 05 04:29 AM
ISNULL function - can't find it KitKat Excel Worksheet Functions 6 December 3rd 04 04:55 AM
Find a Function to use accross different worksheets R. Hale Excel Worksheet Functions 3 November 25th 04 07:07 AM


All times are GMT +1. The time now is 07:18 AM.

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

About Us

"It's about Microsoft Excel"