I have two sheets of stock data from a stock screener, both same
parameters, just different time frames (i.e., one sheet is newer
whenever I import new a new screen from the Internet), which will pull
different stocks as time passes. I'm trying to compare the two sheets
and extract the stock data (a whole row's worth of data, not just a
cell) that is unique to the "Last Import" sheet. This would allow any
new stocks identified on the screener to be transferred to a new sheet
(called "Filtered List"). That way I don't have to research the same
stocks over and over, only the new ones that show up with each import.
I did some searching on the Internet and found the following code,
which I modified to include the sheet names:
Sub CompareMove()
'
Dim lastrowsh1 As Long, lastrowsh2 As Long, lastrowsh3 As Long
Dim searchRng As Range, foundRng As Range
Dim Ws1 As Worksheet, Ws2 As Worksheet, Ws3 As Worksheet
lastrowsh1 = Worksheets("Previous
Import").Range("a65536").End(xlUp).Row
lastrowsh2 = Worksheets("Last
Import").Range("a65536").End(xlUp).Row
lastrowsh3 = Worksheets("Filtered
List").Range("a65536").End(xlUp).Row
Set Ws1 = Worksheets("Previous Import")
Set Ws2 = Worksheets("Last Import")
Set Ws3 = Worksheets("Filtered List")
Set searchRng = Ws2.Columns(1) 'sets column a on Previous Import
With Ws2
For x = 5 To lastrowsh2
Set foundRng = searchRng.Find(Ws1.Cells(x, 1)) 'loop through the
previous import
If Not foundRng Is Nothing Then
foundRng.EntireRow.Copy 'on a match copy row
Ws3.Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial
End If
Next x
End With
End Sub
This is almost what I'm looking for, right now when it runs it extracts
the data COMMON to both sheets, rather than what is UNIQUE which is
what I need it to do. It looks like I'm sooooo close...can someone
tell me what code I need to modify to make it do this? I don't have
too much knowledge outside of basic macro building, and I would be very
grateful for ANY assistance y'all could provide.
Thanks in advance...
Bookmarks