#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Comparing

Does anyone know how to do this?

It compares whatever is in Col. A in this case "sam" and "Tom" with any
matches in Col. A of compare sheet and if it finds one, it will copy and
paste the corresponding cells from master sheet into compare sheet. Now in
compare sheet there are only 2 sams and in master sheet there are 4 sams, so
it should find matches for 2 sams from master sheet and copy them to compare
sheet and the other sams below 2 sams in compare sheet.


Master sheet:

A B C D
sam 1 10 100
sam 2 20 200
sam 3 30 300
sam 4 40 400
Tom 5 6 7

Compare sheet:

A B C D
Sam
Sam
Tom

Compare sheet after running the program:

A B C D
Sam 1 10 100
Sam 2 20 200
3 30 300
4 40 400
Tom 5 6 7

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Comparing

Sub Macro1()
Dim iRow As Integer
Dim ws As Worksheet
Dim ws2 As Worksheet
iRow = 2
Set ws = Sheets("Master")
Set ws2 = Sheets("Compare")
Do
If ws.Cells(iRow, 1) < ws2.Cells(iRow, 1) _
Then ws2.Cells(iRow, 1).Insert Shift:=xlDown
ws.Range("B" & iRow & ":D" & iRow).Copy _
ws2.Range("B" & iRow)
iRow = iRow + 1
Loop Until ws.Cells(iRow, 1) = ""

End Sub

Hth,
Merjet

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 pierre Excel Discussion (Misc queries) 2 May 6th 10 06:02 AM
comparing Donna[_2_] Excel Worksheet Functions 3 November 3rd 09 01:45 AM
Comparing more than two Vern Excel Worksheet Functions 4 September 24th 08 04:03 PM
comparing worksheets Lynn[_7_] Excel Programming 6 November 28th 05 04:27 PM
Comparing Kirk[_4_] Excel Programming 1 December 2nd 03 08:35 PM


All times are GMT +1. The time now is 09:44 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"