VBA sum data in certain columns based on common data

Forrtis

New Member
Joined
Apr 4, 2018
Messages
18
I have a very similar problem to the one in the link below:

https://www.mrexcel.com/forum/excel...plicate-rows-sum-values-certain-column-4.html

The only difference is the formatting of the data. The unsorted data comes in the following format:

GHIJKLMN
1
IDNameBlank columnBlank ColumnBlank ColumnQuantityUnit priceTotal
223X1Y15L*M
341X2Y215L*M
441X2Y315L*M
523X1Y45L*M
641X2Y515L*M

<tbody>
</tbody>


The expected results is similar to the quoted thread, although there are slight differences:
  • Columns L and N need to be summed
  • Columns I, J and K need to stay blank
  • Any number of rows may contain common data in cells belonging to columns G, H and M
    • Values in Column M may be common for two different ID's therefore this column cannot be used as a guide to consolidate the data
    • Either Column G or H can be used to look for common data and then the common rows need to be summed - only summing the columns indicated above
  • There are ~100 different ID's to work with so the code needs to be able to handle this



GHIJKLMN
1
IDNameBlank columnBlank ColumnBlank ColumnQuantityUnit priceTotal
223X1Y1+Y45L*M
341X2Y2+Y3+Y515L*M

<tbody>
</tbody>

Any help would be greatly appreciated!
****** id="cke_pastebin" style="position: absolute; top: 573px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
L*M

<tbody>
</tbody>
aNYa</body>
 
I have shifted everything to the right because I added some columns, however I have changed the code accordingly and it has worked fine until the problem that I have described above.
Please see attached file as requested.


https://app.box.com/s/09u9lazadghaegq3m2qh1rmq0bdwhamw

There are two cases that I have found the code not to work in:
- if you press the button in A2 until no data is left
- if you press the button in A3 until only one range of data is left

Try for yourself if you like, thanks for your help again!
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try the below:=
Add line show in red and a "1" in Red
also add a "End if" at the bottom of the code
Code:
With Sheets("DN Compile")
     Set Rng = .Range("J2", .Range("J" & Rows.Count).End(xlUp))
End With
[COLOR="#FF0000"][B]If Not Rng(1).Address(0, 0) = "J1" Then
[/B][/COLOR]With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
ReDim Ray(1 To Rng.Count [COLOR="#FF0000"][SIZE=4][B]+ 1,[/B][/SIZE][/COLOR] 1 To 8)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,560
Messages
6,120,222
Members
448,951
Latest member
jennlynn

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