URGENTLY NEED HELP - VBA Sumif copy into another sheet

MVert

New Member
Joined
Nov 30, 2016
Messages
1
Hi Guys,

I've been pulling hair trying to do this:

Basically I have a list of transactions, which I have reference via CONCATENATE and also reference them in another sheet.

What I'm trying to do is write a code so that it runs through all the cells in a range, compares it to the others in that range; if they are the same; add them up and then copy and paste the results in the respective cell in the other sheet.... I know theres a simple way but my head hurts from hitting the wall... Please help

Here's the variations of Code I have been working with:

Code 1

#
Sub Test2()


For Each i In Worksheets("Transactions").Range("$C$12:$C$1503")


If (i > 0) Then


Set datacell = Range(i)


sumdf = Application.WorksheetFunction.SumIfs(Range("$C$12:$C$1503"), datacell, Range("$P$12:$P$1503"))


Worksheets("test").Range(i) = sumdf




End If
Next i
End Sub
#


Code 2
#
Sub TRANINPUTDATA()


For Each i In Worksheets("Transactions").Range("$C$12:$C$1503")


If (i > 0) Then


X = WorksheetFunction.Match((i), Range("$C$12:$C$1503"), 0)


If X > 1 Then


Funcy = Application.SumIf(Worksheets("Transactions").Range("$P$12:$P$1503"), X).Copy




Worksheets("test").Range(i).PasteSpecial xlPasteValues


Else


If i <> X Then


i.Offset(0, 13).Copy


Worksheets("test").Range(i).PasteSpecial xlPasteValues




End If
End If
End If


Next i


End Sub
#
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,907
Messages
6,122,181
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top