Help Creating a simple Macro Combining rows based on determining factors

mnty89

Board Regular
Joined
Apr 1, 2016
Messages
66
Ok so some quick random sample data below for the scenario.

So basically I need to do the following per Account(column A)


Each account will have a Department- column C. I need to create a single row for each Department within each Account that combines the values on Columns F-K, the dates. They are divided into two rows based on the option fields for whether they go into one or another, but I basically need them to just skip the blanks, ignore the options and just put all of the values per department into a single row. I put an after version of what I'm hoping for below the original sample as well to illustrate it better than I can explain. I feel like this is very simple, but I'm not sure how to approach it.

Any help is amazing! Thank you!



Original:

[TABLE="width: 782"]
<colgroup><col><col><col><col span="8"></colgroup><tbody>[TR]
[TD]Account Name[/TD]
[TD]Account code[/TD]
[TD]Department[/TD]
[TD]Option A[/TD]
[TD]Option B[/TD]
[TD]January[/TD]
[TD]February[/TD]
[TD]March[/TD]
[TD]April[/TD]
[TD]May[/TD]
[TD]June[/TD]
[/TR]
[TR]
[TD]Account 1 [/TD]
[TD]123456[/TD]
[TD]1[/TD]
[TD]A[/TD]
[TD] [/TD]
[TD]10[/TD]
[TD]24[/TD]
[TD]17[/TD]
[TD]19[/TD]
[TD]34[/TD]
[TD]13[/TD]
[/TR]
[TR]
[TD]Account 1 [/TD]
[TD]123456[/TD]
[TD]2[/TD]
[TD]A[/TD]
[TD][/TD]
[TD]21[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]45[/TD]
[TD]22[/TD]
[TD]13[/TD]
[/TR]
[TR]
[TD]Account 1 [/TD]
[TD]123456[/TD]
[TD]2[/TD]
[TD] [/TD]
[TD]B[/TD]
[TD] [/TD]
[TD]35[/TD]
[TD]44[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Account 2[/TD]
[TD]234567[/TD]
[TD]1[/TD]
[TD]A[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]42[/TD]
[TD]49[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Account 2[/TD]
[TD]234567[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]B[/TD]
[TD]33[/TD]
[TD]25[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]43[/TD]
[TD]22[/TD]
[/TR]
[TR]
[TD]Account 2[/TD]
[TD]234567[/TD]
[TD]2[/TD]
[TD]A[/TD]
[TD][/TD]
[TD] [/TD]
[TD]26[/TD]
[TD]48[/TD]
[TD]44[/TD]
[TD] [/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]Account 2[/TD]
[TD]234567[/TD]
[TD]2[/TD]
[TD] [/TD]
[TD]B[/TD]
[TD]26[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]24[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Account 3[/TD]
[TD]345678[/TD]
[TD]1[/TD]
[TD]A[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]36[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]39[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Account 3[/TD]
[TD]345678[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]B[/TD]
[TD]35[/TD]
[TD] [/TD]
[TD]36[/TD]
[TD]18[/TD]
[TD] [/TD]
[TD]19[/TD]
[/TR]
[TR]
[TD]Account 3[/TD]
[TD]345678[/TD]
[TD]2[/TD]
[TD]A[/TD]
[TD][/TD]
[TD]14[/TD]
[TD]26[/TD]
[TD]10[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Account 3[/TD]
[TD]345678[/TD]
[TD]2[/TD]
[TD] [/TD]
[TD]B[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]44[/TD]
[TD]25[/TD]
[TD]11[/TD]
[/TR]
</tbody>[/TABLE]

End Result:

[TABLE="width: 660"]
<colgroup><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]Account Name[/TD]
[TD]Account code[/TD]
[TD]Department[/TD]
[TD]Option A[/TD]
[TD]Option B[/TD]
[TD]January[/TD]
[TD]February[/TD]
[TD]March[/TD]
[TD]April[/TD]
[TD]May[/TD]
[TD]June[/TD]
[/TR]
[TR]
[TD]Account 1 [/TD]
[TD]123456[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD]19[/TD]
[TD]18[/TD]
[TD]23[/TD]
[TD]42[/TD]
[TD]12[/TD]
[TD]28[/TD]
[/TR]
[TR]
[TD]Account 1 [/TD]
[TD]123456[/TD]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD]35[/TD]
[TD]11[/TD]
[TD]24[/TD]
[TD]49[/TD]
[TD]23[/TD]
[TD]18[/TD]
[/TR]
[TR]
[TD]Account 2[/TD]
[TD]234567[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD]39[/TD]
[TD]34[/TD]
[TD]32[/TD]
[TD]30[/TD]
[TD]33[/TD]
[TD]25[/TD]
[/TR]
[TR]
[TD]Account 2[/TD]
[TD]234567[/TD]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD]32[/TD]
[TD]25[/TD]
[TD]23[/TD]
[TD]34[/TD]
[TD]34[/TD]
[TD]47[/TD]
[/TR]
[TR]
[TD]Account 3[/TD]
[TD]345678[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD]28[/TD]
[TD]36[/TD]
[TD]45[/TD]
[TD]38[/TD]
[TD]49[/TD]
[TD]18[/TD]
[/TR]
[TR]
[TD]Account 3[/TD]
[TD]345678[/TD]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD]11[/TD]
[TD]49[/TD]
[TD]49[/TD]
[TD]26[/TD]
[TD]26[/TD]
[TD]42[/TD]
[/TR]
</tbody>[/TABLE]
 

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