+ Reply to Thread
Results 1 to 4 of 4

Search, copy and paste across multiple worksheets

  1. #1
    Registered User
    Join Date
    10-12-2011
    Location
    Hull, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Smile Search, copy and paste across multiple worksheets

    Hi all, first post!

    Apologies if this is meant to be in the Excel Functions forum

    I have a workbook with 6 worksheets in, 5 worksheets contain data whilst the 6th I will use as a search worksheet. The 5 data worksheets contain columns A to J which have text entries in.

    What I would like help with is for me to click a button on the search worksheet, lets call it worksheet 1, and for an inputbox to allow the user to enter a text search. The macro would then search for this text in columns A to J and all rows (or rows with data in) on the 5 data worksheets, and if found, copy the entire contents of those rows where the text is found and paste them into worksheet 1, the search sheet.

    I have done a forum search and found a few examples of this type of search but not across multiple worksheets, also I found this code that does search across multiple sheets but does not copy and paste:

    Sub Find_Data()
    Dim datatoFind
    Dim sheetCount As Integer
    Dim counter As Integer
    Dim currentSheet As Integer
    On Error Resume Next
    currentSheet = ActiveSheet.Index
    datatoFind = InputBox("Please enter the value to search for")
    If datatoFind = "" Then Exit Sub
    sheetCount = ActiveWorkbook.Sheets.Count
    If IsError(CDbl(datatoFind)) = False Then datatoFind = CDbl(datatoFind)
    For counter = 1 To sheetCount
    Sheets(counter).Activate
    Cells.Find(What:=datatoFind, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False).Activate
    If ActiveCell.Value = datatoFind Then Exit Sub
    Next counter
    If ActiveCell.Value <> datatoFind Then
    MsgBox ("Value not found")
    Sheets(currentSheet).Activate
    End If
    End Sub

    I've also tried an autofilter but this only searches one column, not all.

    Hope I've been clear, any help much appreciated

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Search, copy and paste across multiple worksheets

    here you go


    Please Login or Register  to view this content.
    Try it out on the attachment : this macro will work well IF the sheets have "full" rows. blanks in the J column could potentially cause problems with the find bottom (.end(xlup)) part.

    try it out and please rate
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    10-12-2011
    Location
    Hull, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Search, copy and paste across multiple worksheets

    Hi GeneralDisarray,

    Thanks for your help, I won't have a chance to try it out until Friday so will report back then.

    Thanks again!

  4. #4
    Registered User
    Join Date
    10-12-2011
    Location
    Hull, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Search, copy and paste across multiple worksheets

    Hi,

    This works great, many thanks for your help!

    take care

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1