Modified code sum repeat data
Solved/Closed
abdelfatah_0230
Posts
73
Registration date
Thursday 18 July 2019
Status
Member
Last seen
23 July 2022
-
8 Oct 2020 à 11:38
abdelfatah_0230 Posts 73 Registration date Thursday 18 July 2019 Status Member Last seen 23 July 2022 - 27 Oct 2020 à 18:11
abdelfatah_0230 Posts 73 Registration date Thursday 18 July 2019 Status Member Last seen 23 July 2022 - 27 Oct 2020 à 18:11
Related:
- Modified code sum repeat data
- The grim reaper who repeat my heart - Download - Adult games
- Tmobile data check - Guide
- Cs 1.6 code - Guide
- Ninja up code ✓ - Android Forum
- Mint mobile data not working ✓ - Network Forum
3 responses
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
12 Oct 2020 à 12:01
12 Oct 2020 à 12:01
Hi Abdel,
Why would a formula produce an incorrect result? Have you tried this one:
=SUMIF(A:A,D2,B:B)
Best regards,
Trowa
Why would a formula produce an incorrect result? Have you tried this one:
=SUMIF(A:A,D2,B:B)
Best regards,
Trowa
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
26 Oct 2020 à 12:37
26 Oct 2020 à 12:37
Hi Abdel,
Your code looks overly complicated, so I decided to write my own. Here is my take on getting the requested task done:
Best regards,
Trowa
Your code looks overly complicated, so I decided to write my own. Here is my take on getting the requested task done:
Sub RunMe()
Dim mFind As Range
Columns("A:A").Copy Columns("D:D")
Columns("D:D").RemoveDuplicates Columns:=1, Header:=xlYes
For Each cell In Range("D2:D" & Range("D1").End(xlDown).Row)
Set mFind = Columns("A:A").Find(what:=cell.Value, lookat:=xlWhole)
fAddress = mFind.Address
Do
cell.Offset(0, 1).Value = cell.Offset(0, 1).Value + mFind.Offset(0, 1).Value
Set mFind = Columns("A:A").FindNext(mFind)
Loop While mFind.Address <> fAddress
Next cell
End Sub
Best regards,
Trowa
abdelfatah_0230
Posts
73
Registration date
Thursday 18 July 2019
Status
Member
Last seen
23 July 2022
26 Oct 2020 à 16:22
26 Oct 2020 à 16:22
thanks Trowa but your code doesn't work well it sums values repeatedly each item it continues summing every time run the macro it supposing summing one if i time even run macro repeatedly
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
27 Oct 2020 à 12:33
27 Oct 2020 à 12:33
Hi Abdel,
When you want to run the code multiple times, then you can clear the results first:
Or use the slightly adjusted code below:
The choice is yours.
Best regards,
Trowa
When you want to run the code multiple times, then you can clear the results first:
Range("D2:E" & Range("E1").End(xlDown).Row).ClearContents
Or use the slightly adjusted code below:
Sub RunMe()
Dim mCount As Long
Dim mFind As Range
Columns("A:A").Copy Columns("D:D")
Columns("D:D").RemoveDuplicates Columns:=1, Header:=xlYes
For Each cell In Range("D2:D" & Range("D1").End(xlDown).Row)
Set mFind = Columns("A:A").Find(what:=cell.Value, lookat:=xlWhole)
fAddress = mFind.Address
Do
mCount = mCount + mFind.Offset(0, 1).Value
Set mFind = Columns("A:A").FindNext(mFind)
Loop While mFind.Address <> fAddress
cell.Offset(0, 1).Value = mCount
mCount = 0
Next cell
End Sub
The choice is yours.
Best regards,
Trowa
abdelfatah_0230
Posts
73
Registration date
Thursday 18 July 2019
Status
Member
Last seen
23 July 2022
27 Oct 2020 à 18:11
27 Oct 2020 à 18:11
many thanks ! Trowa it's perfect
17 Oct 2020 à 06:21
thanks again