Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Match and Reconcile

I have a need for a macro to do a simple match of figures in 2 sheets:

The macro should match Amt, REF and RT in sheets 1&2
Where there is match, should write in sheet2 corresponding S/N from
sheet1

Sheet1
S/N Amt REF RT

001 200 w1 john
002 100 e3 Pet
003 400 y7 Yep
004 600 z7 Pet


Sheet2
S/N Amt REF RT

001 400 y7 Yep
002 200 w1 john
003 100 e3 Pet
004 600 z7 Pet


Assumption
The number of row undetermined


Result format: the final result in sheet2 should appear as shown
below.

Sheet2
S/N Amt REF RT S/N(from sheet1)

001 400 y7 Yep 003
002 200 w1 john 001
003 100 e3 Pet 002
004 600 z7 Pet 004
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Match and Reconcile

HI

Try this:

Sub Compare()
Dim ShA As Worksheet
Dim ShB As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim f As Range

Set ShA = Worksheets("Sheet1")
Set ShB = Worksheets("Sheet2")

FirstRow = 3 'First row with data
LastRow = ShA.Range("A" & Rows.Count).End(xlUp).Row

For r = FirstRow To LastRow
Set f = ShB.Columns("B").Find(what:=ShA.Range("B" & r).Value,
LookIn:=xlValues, lookat:=xlWhole)
If Not f Is Nothing Then
If ShA.Range("C" & r) = f.Offset(0, 1).Value And ShA.Range("D" &
r).Value = f.Offset(0, 2).Value Then
f.Offset(0, 3) = ShA.Range("A" & r).Value
End If
End If
Set f = Nothing
Next
End Sub

Regards,
Per

"sylink" skrev i meddelelsen
...
I have a need for a macro to do a simple match of figures in 2 sheets:

The macro should match Amt, REF and RT in sheets 1&2
Where there is match, should write in sheet2 corresponding S/N from
sheet1

Sheet1
S/N Amt REF RT

001 200 w1 john
002 100 e3 Pet
003 400 y7 Yep
004 600 z7 Pet


Sheet2
S/N Amt REF RT

001 400 y7 Yep
002 200 w1 john
003 100 e3 Pet
004 600 z7 Pet


Assumption
The number of row undetermined


Result format: the final result in sheet2 should appear as shown
below.

Sheet2
S/N Amt REF RT S/N(from sheet1)

001 400 y7 Yep 003
002 200 w1 john 001
003 100 e3 Pet 002
004 600 z7 Pet 004


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Match and Reconcile

On Dec 10, 3:55*pm, "Per Jessen" wrote:
HI

Try this:

Sub Compare()
Dim ShA As Worksheet
Dim ShB As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim f As Range

Set ShA = Worksheets("Sheet1")
Set ShB = Worksheets("Sheet2")

FirstRow = 3 'First row with data
LastRow = ShA.Range("A" & Rows.Count).End(xlUp).Row

For r = FirstRow To LastRow
* * Set f = ShB.Columns("B").Find(what:=ShA.Range("B" & r).Value,
LookIn:=xlValues, lookat:=xlWhole)
* * If Not f Is Nothing Then
* * * * If ShA.Range("C" & r) = f.Offset(0, 1).Value And ShA.Range("D" &
r).Value = f.Offset(0, 2).Value Then
* * * * * * f.Offset(0, 3) = ShA.Range("A" & r).Value
* * * * End If
* * End If
* * Set f = Nothing
Next
End Sub

Regards,
Per

"sylink" skrev i ...

I have a need for a macro to do a simple match of figures in 2 sheets:


The macro should match Amt, REF and RT in sheets 1&2
Where there is match, should write in sheet2 corresponding S/N from
sheet1


Sheet1
S/N Amt REF *RT


001 200 w1 john
002 100 e3 Pet
003 400 y7 Yep
004 600 z7 Pet


Sheet2
S/N Amt REF *RT


001 400 y7 Yep
002 200 w1 john
003 100 e3 Pet
004 600 z7 Pet


Assumption
The number of row undetermined


Result format: the final result in sheet2 should appear as shown
below.


Sheet2
S/N Amt REF *RT S/N(from sheet1)


001 400 y7 Yep 003
002 200 w1 john 001
003 100 e3 Pet 002
004 600 z7 Pet 004


Thank you Per. I'll give a try.
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
Trying to reconcile a column michaelcooper Excel Discussion (Misc queries) 1 December 15th 09 09:47 PM
Macro to match / reconcile data : One to Many [email protected] Excel Programming 0 January 22nd 09 09:43 AM
Macro to match / reconcile data : One to Many [email protected] Excel Worksheet Functions 1 January 22nd 09 09:37 AM
Reconcile Inventories Using excel Greg Excel Worksheet Functions 10 February 6th 08 11:55 PM
form for bank reconcile Michele Charts and Charting in Excel 1 December 1st 07 05:42 PM


All times are GMT +1. The time now is 09:56 AM.

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"