MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 8th, 2002, 11:34 PM   #1
robfo0
Board Regular
 
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
Default

Hi everyone,

I found Dave Hawley's code to start the Ctrl+F find box, but I'm have a few problems. I'm trying to select all the sheets so that the find will look through them all, but when i use this code:

Sheets(Array("Active", "Inactive")).Select
Application.Dialogs(xlDialogFormulaFind).Show

the search comes up empty handed. I have no idea why. I can see they are selected, and the data im searching for i can see on the sheet.

Also, is there a way to control this find more? I would like it NOT to search a certain column, say K for example.

Thanks!
robfo0 is offline   Reply With Quote
Old Mar 9th, 2002, 01:45 AM   #2
Dave Hawley
Banned
 
Join Date: Feb 2002
Posts: 1,582
Default

Hi robfo0


Funny you should mention this as it's one of the topics I cover mt latest newsletter, due out next week. Anyway, rather than display the Find dialog you maybe better off simply using a inputbox to collect the word(s) to be searched for. Try the code below to get you started.


Sub FindString()
Dim wsSheet As Worksheet
Dim rFound As Range
Dim strFind As String

strFind = InputBox(Prompt:="Enter the word(s) you would like to find")
If strFind = "" Then Exit Sub
For Each wsSheet In ThisWorkbook.Worksheets
wsSheet.Range("K:K").EntireColumn.Hidden = True
Set rFound = wsSheet.UsedRange. _
Find(What:=strFind, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not rFound Is Nothing Then
Application.Goto rFound, Scroll:=True
wsSheet.Range("K:K").EntireColumn.Hidden = False
End
End If
wsSheet.Range("K:K").EntireColumn.Hidden = False
Next wsSheet

MsgBox "No match"
End Sub




It will search through each Worksheet looking for a match, but hides Column K before each sheet search(Find wont look in hidden rows/columns) then unhides when done. If a match is found the user will be taken straight there. You may want to change these arguments to suit.

LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False

At present it is looking in vales (not formulas), at whole cells (not part) and is NOT case sensitive.


Dave Hawley is offline   Reply With Quote
Old Mar 9th, 2002, 01:57 AM   #3
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Quote:
On 2002-03-08 22:34, robfo0 wrote:
Hi everyone,

I found Dave Hawley's code to start the Ctrl+F find box, but I'm have a few problems. I'm trying to select all the sheets so that the find will look through them all, but when i use this code:

Sheets(Array("Active", "Inactive")).Select
Application.Dialogs(xlDialogFormulaFind).Show

the search comes up empty handed. I have no idea why. I can see they are selected, and the data im searching for i can see on the sheet.

Also, is there a way to control this find more? I would like it NOT to search a certain column, say K for example.

Thanks!
The Find function within the Excel App is one
of those functions that not only holds it's
Value BUT is not Modal and calling it from a
VBA routine means you have to select the
range it works in......try using the ID
number which works for most versions of
excel eg.

Sub MySearch()

Sheets(Array("Active", "Inactive")).Select

Cells.Select
With Application
.CommandBars.FindControl(id:=1849).Execute
End With

End Sub


Ivan

[ This Message was edited by: Ivan F Moala on 2002-03-09 01:25 ]
Ivan F Moala is offline   Reply With Quote
Old Mar 9th, 2002, 02:52 AM   #4
robfo0
Board Regular
 
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
Default

Thanks for the quick response guys, but I'm still having some problems.

Dave, your code works, but the reason i wanted to use the Ctrl F was in my sheets, there are some cells with simliar names, so i want the user to be able to go to the next match if the first wasnt the one they were looking for.

Ivan, can you explain the id a bit to me? ive never seen it before.

Another problem, when i select both sheets manually, then Ctrl F, and type for instance "windows", the search will find the first cell containing 'windows", but when i use any of the codes given (Dave's or Ivan's), the search only comes up with a match if the criteria is EXACTLY what is in the cell. Most of the time, the criteria im looking for isnt alone in a cell. Is it possible to change:
Find(What:=strFind,

and have:

Find(What:=*strFind*,

or something to that effect? i tried it, but i get errors.

Thanks again
robfo0 is offline   Reply With Quote
Old Mar 9th, 2002, 03:00 AM   #5
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Use Daves.......

The code I submitted worked for me in finding
matches ??

Ivan
Ivan F Moala is offline   Reply With Quote
Old Mar 9th, 2002, 03:13 AM   #6
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Quote:
On 2002-03-09 01:52, robfo0 wrote:
Thanks for the quick response guys, but I'm still having some problems.

Dave, your code works, but the reason i wanted to use the Ctrl F was in my sheets, there are some cells with simliar names, so i want the user to be able to go to the next match if the first wasnt the one they were looking for.

Ivan, can you explain the id a bit to me? ive never seen it before.

Thanks again
Each element of the CommandBars collection uses a unique number for its ID property. This number determines the built-in action for each control in the CommandBars collection....so identifying each command ID
will exercute that action eg try this;

Sub about()
Application.CommandBars.FindControl(ID:=927).Execute
End Sub


Ivan
Ivan F Moala is offline   Reply With Quote
Old Mar 9th, 2002, 03:17 AM   #7
robfo0
Board Regular
 
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
Default

OH, i found why it wouldnt find my search in your code ivan, "Find entire cells only" was checked

the other questions still stand though!
robfo0 is offline   Reply With Quote
Old Mar 9th, 2002, 03:21 AM   #8
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

See above.......just missed your post
Ivan F Moala is offline   Reply With Quote
Old Mar 9th, 2002, 03:21 AM   #9
robfo0
Board Regular
 
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
Default

Thanks ivan, thats why my first code wouldnt work hey? Well, I guess i could show the users how to use the Ctrl F manually, its just sometimes a pain, they ALWAYS find a way to mess something up, just trying to make it as painless as possible, for me and them
robfo0 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 07:04 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes