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
#
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
#