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 May 6th, 2002, 10:09 AM   #1
Herman
New Member
 
Join Date: Feb 2002
Posts: 28
Default

I have a question.

i have 3 sheets, i like to search for a value for example 3 in the first 2 sheets
and if it is found in sheetsthen copy the row from the sheet and paste it in sheet3, the same for sheet2 if it is also found there then copy it in sheet3.
number of sheets is not always the same so i thought for each ws , but i get lost after it.

anyone knows how to search across multiple sheets and paste it in 1 sheet.
Herman is offline   Reply With Quote
Old May 6th, 2002, 10:32 AM   #2
zacemmel
Board Regular
 
zacemmel's Avatar
 
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
Default

I have the answer to your question, but I'm not going to give it to you.
zacemmel is offline   Reply With Quote
Old May 6th, 2002, 10:51 AM   #3
Herman
New Member
 
Join Date: Feb 2002
Posts: 28
Default

Why not, if i have done something wrong please tell me so i won't do it again.
i am not aware of doing anything wrong here..
i thought this board was about helping other people.

greetings herman
Herman is offline   Reply With Quote
Old May 6th, 2002, 11:09 AM   #4
Asala42
Board Regular
 
Join Date: Feb 2002
Location: Southfield,MI USA
Posts: 1,027
Default

Heya Herm,

I honestly have no clue whether Zac was joking or was legitimately irked at something - I'm guessing he was playing with you unless there's another thread I missed. Moving onward:

Are you looking specifically for a VBA solution or perhaps something with formulas. I'm still on the beginner side of the VBA pool, but for formula's I'm guessing a series of VLOOKUPs will do the trick.

Can you give out more of the specifics of what you've got in front of you? If a formula approach is ok I'm guessing you'll want either a VLOOKUP/IF or VLOOKUP/INDIRECT combo depending on how many sheets your dealing with.

Hope that helps,
Adam

Asala42 is offline   Reply With Quote
Old May 6th, 2002, 11:10 AM   #5
zacemmel
Board Regular
 
zacemmel's Avatar
 
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
Default

Nothing personal Herman; I was just kidding around
zacemmel is offline   Reply With Quote
Old May 6th, 2002, 11:14 AM   #6
Herman
New Member
 
Join Date: Feb 2002
Posts: 28
Default

A vlookup is working fine on 1 sheet, but i want to search on all sheets and copy multiple found rows to another blank sheet and that isn;t working yet.

Herman
Herman is offline   Reply With Quote
Old May 6th, 2002, 11:18 AM   #7
zacemmel
Board Regular
 
zacemmel's Avatar
 
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
Default

Vlookup doesn't work with 3D references. I would suggest using VBA.
zacemmel is offline   Reply With Quote
Old May 6th, 2002, 11:23 AM   #8
Asala42
Board Regular
 
Join Date: Feb 2002
Location: Southfield,MI USA
Posts: 1,027
Default

How many sheets do you need to search through?

More = More likely you want a VBA solution.

I take it these sheets are set up symetric to each other? If so what ranges (for future example's sake)

Adam
Asala42 is offline   Reply With Quote
Old May 6th, 2002, 11:27 AM   #9
Herman
New Member
 
Join Date: Feb 2002
Posts: 28
Default

I have to look in aprox. 10 sheets.
sheets are not al the same, the column where the value stands i am looking for is always column b.
searching for value 1224 in 10 sheets could result in 4 found(sheet1,sheet5,sheet6,sheet7)
i want to have all the found rows in the sheets in one new worksheet.
Herman is offline   Reply With Quote
Old May 6th, 2002, 01:03 PM   #10
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

You could try a procedure along the following lines:

Code:
Sub Search_Entire_Workbook()
Dim n As Integer, sht As Worksheet, act As Range, act2 As Range, tmpact As Range
Dim o As Long
myVar = InputBox("Please Enter Search Term")
Application.ScreenUpdating = False
n = Sheets.Count
o = 2
Sheets.Add After:=Sheets(n)
On Error GoTo errorhandler
Sheets(n + 1).Name = "SearchResults"
Sheets("SearchResults").[a1] = "Results:"
n = Sheets.Count
For Each sht In ThisWorkbook.Worksheets
    If sht.Index = n Then Exit Sub
    Set act = sht.Cells.Find(What:=myVar)
    If Not act Is Nothing Then
    act.EntireRow.Copy Sheets(n).Range("a" & o)
    Sheets(n).Range("a" & o).AddComment Text:="result location: " & _
        sht.Name & "!" & act.Address
    Set tmpact = act
again:
    Set act2 = sht.Cells.Find(What:=myVar, After:=tmpact)
    If Not act2 Is Nothing Then
        If act2.Address = act.Address Then
            Else:
            If o < 65536 Then
            o = o + 1
            act2.EntireRow.Copy Sheets(n).Range("a" & o)
            Sheets(n).Range("a" & o).AddComment Text:="result location: " & _
                sht.Name & "!" & act2.Address
            Set tmpact = act2
            GoTo again
            Else: MsgBox "Your search has returned too many rows to process."
            Exit Sub
            End If
        End If
    End If
    End If
    If o < 65536 Then
    o = o + 1
    Else: MsgBox "Your search has returned too many rows to process."
    Exit Sub
    End If
Next sht
Application.ScreenUpdating = True
Exit Sub
errorhandler:
Application.ScreenUpdating = True
MsgBox ("You need to delete the results sheet before running this procedure." _
    & Chr(13) & Chr(13) & "Delete the sheet ""SearchResults,"" then run again.")
Application.DisplayAlerts = False
Sheets(Sheets.Count).Delete
Application.DisplayAlerts = True
End Sub
Place it in a normal module and give her a whirl. She's built to find your value no matter what column, no matter what type of searcheable material, no matter which row has blank cells, etc..... Hope this helps.

_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-07 09:11 ]
NateO 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 11:09 AM.


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