jakeman
Active Member
- Joined
- Apr 29, 2008
- Messages
- 325
- Office Version
- 365
- Platform
- Windows
Hi there - I'm working with a data set that is in a less than friendly format. I'm trying to turn this data set into a more user friendly format for querying and pivot tables.
Here's how the data is currently structured:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Business Entity[/TD]
[TD]Control1[/TD]
[TD]Control2[/TD]
[TD]Control3[/TD]
[TD]Control4[/TD]
[TD]Control5[/TD]
[TD]Control6[/TD]
[TD]Control7[/TD]
[TD]Control8[/TD]
[TD]Control9[/TD]
[TD]Control10[/TD]
[/TR]
[TR]
[TD]Legal[/TD]
[TD]Cntl_001[/TD]
[TD]Cntl_002[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Marketing[/TD]
[TD]Cntl_001[/TD]
[TD]Cntl_002[/TD]
[TD]Cntl_005[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Operations[/TD]
[TD]Cntl_017[/TD]
[TD]Cntl_018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Investments[/TD]
[TD]Cntl_006[/TD]
[TD]Cntl_007[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Instead of the above format, I'd like to write a macro that will step through each column where there is a control listed and if there is more than one control, it will append the Business Entity and the Control number to a new row. So I'd like my new list to look this way:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Business Entity[/TD]
[TD]Control #[/TD]
[/TR]
[TR]
[TD]Legal[/TD]
[TD]Cntl_001[/TD]
[/TR]
[TR]
[TD]Legal[/TD]
[TD]Cntl_002[/TD]
[/TR]
[TR]
[TD]Marketing[/TD]
[TD]Cntl_001[/TD]
[/TR]
[TR]
[TD]Marketing[/TD]
[TD]Cntl_002[/TD]
[/TR]
[TR]
[TD]Marketing[/TD]
[TD]Cntl_005[/TD]
[/TR]
[TR]
[TD]Operations[/TD]
[TD]Cntl_017[/TD]
[/TR]
[TR]
[TD]Operations[/TD]
[TD]Cntl_018[/TD]
[/TR]
[TR]
[TD]Investments[/TD]
[TD]Cntl_006[/TD]
[/TR]
[TR]
[TD]Investments[/TD]
[TD]Cntl_007[/TD]
[/TR]
</tbody>[/TABLE]
Can anyone share a method for this approach?
Here's how the data is currently structured:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Business Entity[/TD]
[TD]Control1[/TD]
[TD]Control2[/TD]
[TD]Control3[/TD]
[TD]Control4[/TD]
[TD]Control5[/TD]
[TD]Control6[/TD]
[TD]Control7[/TD]
[TD]Control8[/TD]
[TD]Control9[/TD]
[TD]Control10[/TD]
[/TR]
[TR]
[TD]Legal[/TD]
[TD]Cntl_001[/TD]
[TD]Cntl_002[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Marketing[/TD]
[TD]Cntl_001[/TD]
[TD]Cntl_002[/TD]
[TD]Cntl_005[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Operations[/TD]
[TD]Cntl_017[/TD]
[TD]Cntl_018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Investments[/TD]
[TD]Cntl_006[/TD]
[TD]Cntl_007[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Instead of the above format, I'd like to write a macro that will step through each column where there is a control listed and if there is more than one control, it will append the Business Entity and the Control number to a new row. So I'd like my new list to look this way:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Business Entity[/TD]
[TD]Control #[/TD]
[/TR]
[TR]
[TD]Legal[/TD]
[TD]Cntl_001[/TD]
[/TR]
[TR]
[TD]Legal[/TD]
[TD]Cntl_002[/TD]
[/TR]
[TR]
[TD]Marketing[/TD]
[TD]Cntl_001[/TD]
[/TR]
[TR]
[TD]Marketing[/TD]
[TD]Cntl_002[/TD]
[/TR]
[TR]
[TD]Marketing[/TD]
[TD]Cntl_005[/TD]
[/TR]
[TR]
[TD]Operations[/TD]
[TD]Cntl_017[/TD]
[/TR]
[TR]
[TD]Operations[/TD]
[TD]Cntl_018[/TD]
[/TR]
[TR]
[TD]Investments[/TD]
[TD]Cntl_006[/TD]
[/TR]
[TR]
[TD]Investments[/TD]
[TD]Cntl_007[/TD]
[/TR]
</tbody>[/TABLE]
Can anyone share a method for this approach?