LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
kilo1990
 
Posts: n/a
Default Compare 2 Sheets and Extract Unique Info to a 3rd Sheet

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...

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referancing differant sheets jp nellie Excel Worksheet Functions 2 November 16th 05 09:19 PM
Extract Unique Records from two lists MarkN Excel Worksheet Functions 3 November 11th 05 01:07 PM
AUTO FILTER NOT CHANGING RESULTS Dejan Excel Discussion (Misc queries) 25 October 6th 05 02:01 PM
Extract sheet name/number to cell claytorm Excel Discussion (Misc queries) 1 June 27th 05 11:34 AM
HELP -- probably a LOOKUP problem Liz-In-USA Excel Discussion (Misc queries) 3 December 9th 04 12:18 AM


All times are GMT +1. The time now is 12:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"