Formatting table using VBA- Need help!

KK3008

New Member
Joined
May 8, 2019
Messages
8
Hi, I've been trying to get this done to analyze the data. However, I am unable to un-pivot this table. Could someone please guide me here?

Input table-

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]A[/TD]
[TD]A[/TD]
[TD]A[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]B[/TD]
[TD]B[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]WEEK[/TD]
[TD]MON[/TD]
[TD]TUE[/TD]
[TD]WED[/TD]
[TD]THURS[/TD]
[TD]FRI[/TD]
[TD]MON[/TD]
[TD]TUE[/TD]
[TD]WED[/TD]
[TD]THURS[/TD]
[TD]FRI[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]100[/TD]
[TD]100[/TD]
[TD]100[/TD]
[TD]100[/TD]
[TD]100[/TD]
[TD]100[/TD]
[TD]100[/TD]
[TD]100[/TD]
[TD]100[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]150[/TD]
[TD]150[/TD]
[TD]150[/TD]
[TD]150[/TD]
[TD]150[/TD]
[TD]150[/TD]
[TD]150[/TD]
[TD]150[/TD]
[TD]150[/TD]
[TD]150[/TD]
[/TR]
</tbody>[/TABLE]







Desired Output-

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Business[/TD]
[TD]Week[/TD]
[TD]Day[/TD]
[TD]Total[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]1[/TD]
[TD]MON[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]1[/TD]
[TD]TUE[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]1[/TD]
[TD]WED[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]1[/TD]
[TD]THURS[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]1[/TD]
[TD]FRI[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]2[/TD]
[TD]MON[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]2[/TD]
[TD]TUE[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]2[/TD]
[TD]WED[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]2[/TD]
[TD]THURS[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]2[/TD]
[TD]FRI[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]1[/TD]
[TD]MON[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]1[/TD]
[TD]TUE[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]1[/TD]
[TD]WED[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]1[/TD]
[TD]THURS[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]1[/TD]
[TD]FRI[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]2[/TD]
[TD]MON[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]2[/TD]
[TD]TUE[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]2[/TD]
[TD]WED[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]2[/TD]
[TD]THURS[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]2[/TD]
[TD]FRI[/TD]
[TD]150[/TD]
[/TR]
</tbody>[/TABLE]
































Thanks in advance!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Cross-posted: https://www.ozgrid.com/forum/forum/...ros/1219363-vba-code-to-format-table-un-pivot

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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