Try this

 

Sub ReMoveDuplicateAndSum()

Dim cell As Range

Dim Rng As Range

    Range("A:A").Copy Range("E1")

    Range("E:E").RemoveDuplicates 1

        

            Set Rng = Range("F2:F" & Range("E10000").End(xlUp).Row)

            Range("F1").Value = "Amount"

            For Each cell In Rng

                cell.Value = WorksheetFunction.SumIf(Range("A:A"),
cell.Offset(0, -1).Value, Range("B:B"))

            Next

                

End Sub

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of NOORAIN ANSARI
Sent: Friday, July 22, 2011 8:52 AM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Re: VBA - Remove duplicate and get sums

 

Dear Raghvendra,

 

Please try below code and see attached sheet....

 

 

Sub advancefilter_sumif()

Dim i, j As Long
Dim abc, cba As Range
Application.ScreenUpdating = False
Sheet1.Range("A1:A" & Sheet1.Range("A1").End(xlDown).Row).Copy
Sheet1.Range("D1").Select
ActiveSheet.Paste
Sheet1.Range("E1").Value = "Amount"
Sheet1.Range("D1:D" & Sheet1.Range("A1").End(xlDown).Row).RemoveDuplicates
1, xlNo
j = Application.WorksheetFunction.CountA(Sheet1.Range("D:D"))
Set abc = Sheet1.Range("A1:A" & Sheet1.Range("A1").End(xlDown).Row)
Set cba = Sheet1.Range("B1:B" & Sheet1.Range("B1").End(xlDown).Row)
For i = 2 To j
Sheet1.Range("E" & i).Value = Application.WorksheetFunction.SumIf(abc,
Sheet1.Range("D" & i).Value, cba)
Next
Application.ScreenUpdating = True
end sub

-- 

Thanks & regards,

Noorain Ansari

 <http://noorain-ansari.blogspot.com/> http://noorain-ansari.blogspot.com/

On Fri, Jul 22, 2011 at 12:24 AM, GoldenLance <samde...@gmail.com> wrote:

A Pivot Table is used precisely for such computations. As a thumb
rule, use Excel functions and tools where Excel can handle it
efficiently. Use VBA only if Excel cannot give desired output on its
own

On Jul 21, 10:19 pm, Raghavendra <raghavendra....@gmail.com> wrote:
> Hi,
>
> Can anyone let me know VBA code for the below?
>
> Input Data
>
> Names   Amount
> A       100
> B       200
> C       100
> B       100
> A       100
> D       150
>
> Out put data should be
>
> Names   Amount
> A       200
> B       300
> C       100
> D       150
>
> Regards,
> Raghavendra

--
----------------------------------------------------------------------------
------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links :
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
<http://www.excel-macros.blogspot.com/> 
4. Learn VBA Macros at http://www.quickvba.blogspot.com
<http://www.quickvba.blogspot.com/> 
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
<http://exceldailytip.blogspot.com/> 

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

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel





-- 
----------------------------------------------------------------------------
------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links :
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com

To post to this group, send email to excel-macros@googlegroups.com
 
<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to