Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Compare 2 sheets against 2 colums

Hi
I have been reading old posts but couldn't find an answer to my prob.
I have two sheets "sales" and "salesold". They have the same fields.
What I want to do is compare "sales" to "salesold" and copy the
different rows into "compare" sheet.Comparing colums are "n" and "m"
ie.

- check value in "n" first if "salesold" doesn't have it then copy row
to "compare" from "sales".
- if "salesold" has it then check "m" column.If the "m"'s is the same
do nothing if different then
copy the row to "compare" from "sales".

Sheet "sales" has all the data which "salesold" can contain of
course.

Any direction ? Thank you very much in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Compare 2 sheets against 2 colums

On 26 Apr., 17:32, wrote:
Hi
I have been reading old posts but couldn't find an answer to my prob.
I have two sheets "sales" and "salesold". They have the same fields.
What I want to do is compare "sales" to "salesold" and copy the
different rows into "compare" sheet.Comparing colums are "n" and "m"
ie.

- check value in "n" first if "salesold" doesn't have it then copy row
to "compare" from "sales".
- if "salesold" has it then check "m" column.If the "m"'s is the same
do nothing if different then
* copy the row to "compare" from "sales".

Sheet "sales" has all the data which "salesold" can contain of
course.

Any direction ? *Thank you very much in advance.


Hi

Try this code

Sub Compare_Sales()

Dim TargetRange As Range
Dim SearchRange As Range
Dim Search2Range As Range
Dim shSales As Variant
Dim shOSales As Variant
Dim shCompare As Variant
Dim fSales As Variant
Dim dCell As String

Set shSales = Sheets("Sales")
Set shOSales = Sheets("Salesold")
Set shCompare = Sheets("Compare")

shSales.Select
Set TargetRange = Range("N2", Range("N2").End(xlDown)) 'Headings in
row # 1

shOSales.Select
Set SearchRange = Range("N2", Range("N2").End(xlDown))

dCell = "A2"

For Each c In TargetRange
Set fSales = SearchRange.Find(what:=c.Value)
If fSales Is Nothing Then
c.EntireRow.Copy shCompare.Range(dCell)
dCell = shCompare.Range(dCell).Offset(1, 0).Address
Else
If c.Offset(0, -1).Value < fSales.Offset(0, -1).Value Then
c.EntireRow.Copy shCompare.Range(dCell)
dCell = shCompare.Range(dCell).Offset(1, 0).Address
End If
End If
Next
End Sub

Regards,
Per
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Compare 2 sheets against 2 colums

Dear Per Jessen

You are definitely not from heaven but this doesn't mean you will
remain here for ever.

Thank you very much.
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
Compare 2 uneven colums MDI Anne Excel Discussion (Misc queries) 2 May 12th 09 01:32 PM
Compare Sheets values in two colums Geir[_2_] Excel Worksheet Functions 1 April 7th 08 01:55 PM
Macro turning colums w/headers into list on multiple sheets MentalDrow Excel Programming 1 April 10th 06 06:32 PM
Compare Sheets wayliff Excel Discussion (Misc queries) 0 January 13th 06 08:14 PM
Need to compare values in two colums and delete accordingly [email protected] Excel Programming 2 January 9th 06 09:17 PM


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