+ Reply to Thread
Results 1 to 3 of 3

Find text on one sheet search through another and place results on third

Hybrid View

  1. #1
    Registered User
    Join Date
    06-12-2011
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2010
    Posts
    3

    Find text on one sheet search through another and place results on third

    Ok here goes bare with me.

    Sheet1 = 1st report is seperated nicly from a:m and 1:3000 (containing text, numbers, symbols in various forms such as abreviations, email addresss, ip address, phone numbers and residental address).

    Sheet2 = (A:K) (1:1000) Restricted names, ip addresses, address (same as above)

    Sheet3= Results wanted here.

    So What I'm tyring to do is use the list in sheet2 to search through sheet1 and if any match then place the results in sheet3 (whole row copy and paste). I have found a Macro to help me with this but not to the extremes that I need.

    My problem is this macro only goes as far as part words in a cell so example being:
    "john abbot" search for john and its found
    "johnabbot" search for john and its not found.

    I hope I have explained it well enough. Code I using is below (and thanks in advance for any help).

    Sub Comparefindpaste()
    Dim srchLen, gName, nxtRw As Integer
    Dim g As Range
    'Clear Sheet 2 and Copy Column Headings
     Sheets(2).Cells.ClearContents
     Sheets(1).Rows(1).Copy Destination:=Sheets(2).Rows(1)
    'Determine length of Search Column from Sheet3
       srchLen = Sheets(3).Range("A" & Rows.Count).End(xlUp).Row
    'Loop through list in Sheet3, Column A:I. As each value is
    'found in Sheet1, Column A:M, copy it top the next row in Sheet2
      With Sheets(1).Columns("A:M")
        For gName = 2 To srchLen
          Set g = .Find(Sheets(3).Range("A" & gName), lookat:=xlPart)
            If Not g Is Nothing Then
              nxtRw = Sheets(2).Range("A" & Rows.Count).End(xlUp).Row + 1
              g.EntireRow.Copy Destination:=Sheets(2).Range("A" & nxtRw)
            End If
        Next
      End With
    End Sub

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Find text on one sheet search through another and place results on third

    Sub Comparefindpaste()
      Sheets(2).usedrange.offset(1).ClearContents
    
      sn= Sheets(3).columns(1).specialcells(2)
      With Sheets(1).Columns("A:M")
        For j = 2 To ubound(sn) 
            If Not .Find(sn(j,1), ,xlvalues,xlPart) Is Nothing Then .parent.row(j).copy = sheets(2).rows(Sheets(2).cells(Rows.Count,1).End(xlUp).Row+ 1)
        Next
      End With
    End Sub



  3. #3
    Registered User
    Join Date
    06-12-2011
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Find text on one sheet search through another and place results on third

    After coping this one in and trying to run it I get an error "Run-time error '438': Object doesn't support this property or method"

    The part it stops at is below

    .Parent.Row(j).Copy = Sheets(2).Rows(Sheets(2).Cells(Rows.Count, 1).End(xlUp).Row + 1)

+ 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