Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Comparing data between sheets, and copying rows with data

I have a list of data on one worksheet, I want to compare the values in this
list of data with values in another column of a different worksheet. When
there is a match between these values I would like to copy the row from the
second worksheet to a completely different worksheet. I have seen some
examples of finding data, and copying data, but do not really have a full
enough understanding of the principles to make this work. In a nutshell I
want to look at sheet 1 column A, compare these values with sheet 2 column M
and if there is a match found copy the row that contains the match from sheet
2 to sheet 3. Can this be done?
Thank you for any assistance you can provide.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Comparing data between sheets, and copying rows with data

Sub copyData()
dim rng1 as Range, rng2 as Range
Dim cell as Range, rw as Long
Dim sh as Worksheet
With worksheets("Sheet1")
set rng1 = .Range(.Cells(1,"A"),.Cells(.rows.count,"A").End(x lup))
End With
With worksheets("Sheet2")
set rng2 = .Range(.Cells(1,"M"),.Cells(.rows.count,"M").End(x lup))
End With
set sh = Worksheets("Sheet3")
rw = 1
for each cell in rng2
if application.countif(rng1,cell) 0 then
cell.EntireRow.copy sh.Cells(rw,"A")
rw = rw + 1
end if
Next
End sub

--
Regards,
Tom Ogilvy

"Fleone" wrote:

I have a list of data on one worksheet, I want to compare the values in this
list of data with values in another column of a different worksheet. When
there is a match between these values I would like to copy the row from the
second worksheet to a completely different worksheet. I have seen some
examples of finding data, and copying data, but do not really have a full
enough understanding of the principles to make this work. In a nutshell I
want to look at sheet 1 column A, compare these values with sheet 2 column M
and if there is a match found copy the row that contains the match from sheet
2 to sheet 3. Can this be done?
Thank you for any assistance you can provide.

Reply
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
Comparing Data on 2 sheets Lee Excel Discussion (Misc queries) 1 November 25th 08 03:45 PM
Comparing Columns, Then copying data jdb Excel Discussion (Misc queries) 1 December 16th 05 07:01 PM
comparing & copying data over from another workbook Twain Excel Programming 1 July 31st 05 05:49 PM
Comparing Data between two sheets AChesley Excel Worksheet Functions 1 February 17th 05 02:02 AM
Comparing data on two sheets Gareth Excel Programming 1 May 18th 04 12:15 PM


All times are GMT +1. The time now is 01:29 PM.

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

About Us

"It's about Microsoft Excel"