+ Reply to Thread
Results 1 to 9 of 9

I need to copy information from one workbook to another workbook using a search function

  1. #1
    Registered User
    Join Date
    02-08-2013
    Location
    Nottingham
    MS-Off Ver
    Excel 2010
    Posts
    6

    Red face I need to copy information from one workbook to another workbook using a search function

    Hi

    First post here gos. I am looking to transfer information from one colomn in one workbook to another cell range i choose in another workbook. But the information from the first workbook needs to be seached through.

    i.e. i need all instances of Oranges to be found and transferred to the other workbook within a cell range of my choice and so on.

    Can this be done. I have been trying Vlookup and several other formulas to no avail.

    Hope some one can help

    Many thanks

  2. #2
    Registered User
    Join Date
    01-30-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: I need to copy information from one workbook to another workbook using a search functi

    frow = Application.WorksheetFunction.Match(Target, Range("YOUR RANGE"), 0)

    Hope it helps.

  3. #3
    Registered User
    Join Date
    02-08-2013
    Location
    Nottingham
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: I need to copy information from one workbook to another workbook using a search functi

    Hi thank you for the quick response I will try it and get back to you

  4. #4
    Registered User
    Join Date
    02-08-2013
    Location
    Nottingham
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: I need to copy information from one workbook to another workbook using a search functi

    Hi so say the first workbook that holds the seachable info is called Exp and the second workbook is called Job and the word i want to search is oranges. How would the formula look. Sorry if im being a biff i just cant work it out.

    frow = Application.WorksheetFunction.Match(Target, Range("YOUR RANGE"), 0) work?

  5. #5
    Registered User
    Join Date
    02-08-2013
    Location
    Nottingham
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: I need to copy information from one workbook to another workbook using a search functi

    Hi so say the first workbook that holds the seachable info is called Exp and the second workbook is called Job and the word i want to search is oranges. How would the formula look. Sorry if im being a biff i just cant work it out.

    frow = Application.WorksheetFunction.Match(Target, Range("YOUR RANGE"), 0) work?

  6. #6
    Registered User
    Join Date
    01-30-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: I need to copy information from one workbook to another workbook using a search functi

    Target = Oranges

    Sheets("EXP").Select
    frow = Application.WorksheetFunction.Match(Target, Range("a1:a100"), 0)
    ' If a1-a100 is the column you're searching through, you could do a1:g100
    ' If you wanted to....

    But I just reread and you need every instance... So that will not work. Sorry.
    I think MATCH only finds the 1st instance using a binary search algo.
    I would say you should run a loop through the column and use the instr function. But that could take some time.
    As to the fastest cleanest way to do this I'm not exactly sure.
    If I have assisted you, please add to my Rep

  7. #7
    Registered User
    Join Date
    02-08-2013
    Location
    Nottingham
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: I need to copy information from one workbook to another workbook using a search functi

    Thank you for your help so grateful, but like you said I do need all instances. Hope some one can help otherwise back to the drawing board

  8. #8
    Registered User
    Join Date
    01-30-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: I need to copy information from one workbook to another workbook using a search functi

    Usually people on here are pretty good, I'm sure one of the Guru Users know a quick way to do this.

    The guy here has a way to find every instance, edit that to do what you want instead of change color maybe?:

    http://www.excelforum.com/excel-prog...using-vba.html
    Last edited by ExcelWizards; 02-15-2013 at 05:41 PM. Reason: Useful Info

  9. #9
    Registered User
    Join Date
    02-08-2013
    Location
    Nottingham
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: I need to copy information from one workbook to another workbook using a search functi

    I have tried this and tweeked the range i want which finds all instances. But I cannot get the info from one work book to another to cells i specify. I just dont have the knowledge. Can anybody help

    Sub boldme()

    With Sheets("Sheet2").Range("E1:E" & Rows.Count)

    Dim MyVal, vFIND As Range, vFIRST As Range

    MyVal = Array("BLADES")

    On Error Resume Next

    For i = 0 To UBound(MyVal)

    Set vFIND = .Find(What:=MyVal(i), lookat:=xlPart, MatchCase:=False, SearchFormat:=False)

    If Not vFIND Is Nothing Then
    Set vFIRST = vFIND
    Do
    For j = -4 To 6
    vFIND.Offset(0, j).Interior.Color = vbRed
    vFIND.Offset(0, j).Font.Bold = True
    Next j
    Set vFIND = .FindNext(vFIND)
    Loop While vFIND.Address <> vFIRST.Address


    End If
    Next i

    MyVal = Array("GENDLE")

    On Error Resume Next

    For i = 0 To UBound(MyVal)

    Set vFIND = .Find(What:=MyVal(i), lookat:=xlPart, MatchCase:=False, SearchFormat:=False)

    If Not vFIND Is Nothing Then
    Set vFIRST = vFIND
    Do
    For j = -4 To 6
    vFIND.Offset(0, j).Interior.Color = vbBlue
    vFIND.Offset(0, j).Font.Bold = True
    Next j
    Set vFIND = .FindNext(vFIND)
    Loop While vFIND.Address <> vFIRST.Address

    End If
    Next i

    MyVal = Array("STEEL")

    On Error Resume Next

    For i = 0 To UBound(MyVal)

    Set vFIND = .Find(What:=MyVal(i), lookat:=xlPart, MatchCase:=False, SearchFormat:=False)

    If Not vFIND Is Nothing Then
    Set vFIRST = vFIND
    Do
    For j = -4 To 6
    vFIND.Offset(0, j).Interior.Color = vbYellow
    vFIND.Offset(0, j).Font.Bold = True
    Next j
    Set vFIND = .FindNext(vFIND)
    Loop While vFIND.Address <> vFIRST.Address

    End If
    Next i
    End With
    Set vFIRST = Nothing
    Set vFIND = Nothing
    End Sub

+ 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