Hi Keechak

 

Try this: See the attached File

 

Sub ShowDifferenc()

    

    Dim ArrTabel1

    Dim rngTabel2 As Range

    Dim ArrResult()

    Dim lngRecordCOunter As Long

    Dim lngFillArray    As Long

    

    lngFillArray = 1

    ArrTabel1 = Range("rngTable1").CurrentRegion

    Set rngTabel2 = Range("rngTable2").CurrentRegion

    ReDim ArrResult(1 To UBound(ArrTabel1) + rngTabel2.Rows.Count, 1 To
UBound(ArrTabel1, 2))

    For lngRecordCOunter = (LBound(ArrTabel1) + 1) To UBound(ArrTabel1)

        If WorksheetFunction.SumIf(rngTabel2, ArrTabel1(lngRecordCOunter,
1), rngTabel2.Columns(2)) < ArrTabel1(lngRecordCOunter, 2) Then

            ArrResult(lngFillArray, 1) = ArrTabel1(lngRecordCOunter, 1)

            ArrResult(lngFillArray, 2) = ArrTabel1(lngRecordCOunter, 2) -
WorksheetFunction.SumIf(rngTabel2, ArrTabel1(lngRecordCOunter, 1),
rngTabel2.Columns(2))

            lngFillArray = lngFillArray + 1

        End If

    Next lngRecordCOunter

    

    ArrTabel1 = Range("rngTable2").CurrentRegion

    Set rngTabel2 = Range("rngTable1").CurrentRegion

    For lngRecordCOunter = (LBound(ArrTabel1) + 1) To UBound(ArrTabel1)

        If WorksheetFunction.SumIf(rngTabel2, ArrTabel1(lngRecordCOunter,
1), rngTabel2.Columns(2)) < ArrTabel1(lngRecordCOunter, 2) Then

            ArrResult(lngFillArray, 1) = ArrTabel1(lngRecordCOunter, 1)

            ArrResult(lngFillArray, 2) = ArrTabel1(lngRecordCOunter, 2) -
WorksheetFunction.SumIf(rngTabel2, ArrTabel1(lngRecordCOunter, 1),
rngTabel2.Columns(2))

            lngFillArray = lngFillArray + 1

        End If

    Next lngRecordCOunter

    

 

    With ThisWorkbook.Worksheets("ResultTable")

        .Range("A2").CurrentRegion.Offset(1).ClearContents

        .Range("A2").Resize(UBound(ArrResult), UBound(ArrResult, 2)).Value =
ArrResult

        .Activate

        MsgBox "Done"

    End With

    

'Free them

Erase ArrResult

Erase ArrTabel1

Set rngTabel2 = Nothing

End Sub

 

 

Regards

Rajan verma

+91 7838100659 [IM-Gtalk]

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of Mr excel
Sent: 09 May 2012 5:24
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Find differences between four columns.

 

Verma bhayya,,
The code is working fine but only one sided.i mean if there are no Receipts
in List 2 which are in List 1 then the code finds the difference only
between these two.how to change the code so that it shows all the missing
receipts with amounts either way...Receipts with amounts not appearing in
list 2 compared with list 1 also...please help...

Thanks in advance....

-- 
FORUM RULES (986+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
 
----------------------------------------------------------------------------
--------------------------
To post to this group, send email to excel-macros@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Attachment: Copy of ShowDifference.xlsm
Description: application/vnd.ms-excel.sheet.macroenabled.12

Reply via email to