Combine rows with duplicate tag

pochi

New Member
Joined
Dec 19, 2017
Messages
1
Hi Everyone.

I'm new to excel and VBA. So maybe the question is a bit dumb.

I got my macro reading different Excel file and combine as a big datasheet.

I am facing problem in combining data.

At First, I got 2 column and the sheet is blank.

NameTotal

<tbody>
</tbody>

After I ran the macro, datasheet will be inserted a column and data will be add

Example (1st Time)
NameAprilTotal
A1
B2
A3

<tbody>
</tbody>

Example (2nd Time)
NameMayAprilTotal
A3
B2
B2
A1
B2
A3

<tbody>
</tbody>


Question is, I would like to get the following output (Note that the data will be added and new column will be insert)

NameMayAprilTotal
A347
B426

<tbody>
</tbody>

I got a function for finding last column and last row (i.e. after 2nd run of inserting data, last column will be 4 and last row will be 7)

I know is a bit dumb and stupid, still i cannot get a clue yet.

Please help and thank you for all the reply.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
There are some folks on these forums that most likely have a slick solution to this sort of problem, but the variable amount of columns does increase the complexity quite a bit. If it was for a single month, I think it would be pretty simple using a dictionary.

If the macro could identify which months were going to be present before pulling the data, it would be easier, but your example doesn't show "May" until the second table. You could just account for 12 months and use a Select Case branch statement to ID the month on each column. If you need the months to show up in a particular order, you'd need to account for that logic in the macro, as well.

It's a worthy task for VBA, but I'd be tempted to build a table and use INDEX/MATCH functions to summarize the data. Otherwise, I'd think it would be done in VBA by using arrays and/or dictionaries, which can be a big learning curve.

Do you have any coding done towards this solution that you can share?
 
Upvote 0

Forum statistics

Threads
1,215,872
Messages
6,127,430
Members
449,382
Latest member
DonnaRisso

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