Solved I want to modify this Excel VB to find the missing words.

January 18, 2012 at 14:08:12
Specs: Macintosh
On this page, post #7 by "DerbyDad03 November 30, 2010" shows a VB code to search words on sheet3 and find them on sheet1 before copying them to sheet2.

I need help to alter this code so that it searches for words on sheet3 that are *missing* from sheet1, before copying the *missing* words from *sheet3* to sheet2.

I'd appreciate any help please.

See More: I want to modify this Excel VB to find the missing words.

Report •

January 18, 2012 at 15:19:05
✔ Best Answer
Option Explicit
Sub NotGeneFinder()
Dim srchLen, gName, nxtRw As Integer
Dim g As Range
'Clear Sheet 2 and Copy Column Headings
 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. If the value is not
'found in Sheet1, Column D, copy the Row from Sheet 3 
'to the next row in Sheet2
  With Sheets(1).Columns("D")
    For gName = 2 To srchLen
      Set g = .Find(Sheets(3).Range("A" & gName), lookat:=xlWhole)
        If g Is Nothing Then
          nxtRw = Sheets(2).Range("D" & Rows.Count).End(xlUp).Row + 1
            Sheets(3).Range("A" & gName).EntireRow.Copy _
              Destination:=Sheets(2).Range("A" & nxtRw)
        End If
  End With
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

January 18, 2012 at 15:33:59
Wow, @DerbyDad03, that was quick.
Thank you.

It's exactly what I've been trying to understand and do.

(I've spent all night, here in Europe, looking at this, and couldn't solve it. I'm new to VB. So now, I'll look closely at your work to understand what you've done.)

Report •

Related Solutions

Ask Question