Microsoft Excel - Search string in column similar then sum the data and result next sheet

Asked By farrukh on 19-Jun-12 03:09 AM
Pichart Y. replied to farrukh on 19-Jun-12 09:14 PM
Hi farukh,

There is not detail in your post, what happen?

pichart Y
farrukh replied to Pichart Y. on 19-Jun-12 10:54 PM
Hello pichart Y

I am really sorry i tried yesterday to attached sheet but vain
the workbook is attached with contains two worksheet one is before other is after i need in before sheet Column C the code look for similar strings and sum them in the after sheet like ?

      data sheet1.zip


Regards,

Hameed
Pichart Y. replied to farrukh on 20-Jun-12 11:41 AM
Hi Hameed,

Try this code...
  • I design to have 2 loops, 
    • x loop get the value for match checking in sheet after
    • y loop to check those matched in after
  • if matched then add the value in column H of that same y row to the value in column H of x row
here is the code
Sub getData()
For Each x In Sheets("after").Range("B2:B4")
    For Each y In Sheets("Before").Range("B2:B10")
        If y = x Then Sheets("After").Range("H" & x.Row) = Sheets("After").Range("H" & x.Row).Value _
        & Sheets("Before").Range("H" & y.Row).Value
    Next y
Next x
End Sub

Hope this help.

pichart Y

farrukh replied to Pichart Y. on 25-Jun-12 01:56 AM
Pichart Y.

Thanks you so much it works great :)


Thanks

hameed