seattletimebandit
Board Regular
- Joined
- Apr 11, 2013
- Messages
- 69
Hello!
Trying to figure out how to take a table of data and split into individual smaller tables. The source data table columns and rows are variable, from a few columns/rows to quite a lot, so maybe a message box asking user to select Range?
or something like:
Dim c1 As Range
Dim c2 As Range
lastColumn = ActiveSheet.Cells(c1.Row, Columns.Count).End(xlToLeft).Column
For Each c2 In Range(Cells(c1.Row, 3), Cells(c1.Row, lastColumn)).
Start with User pasting the Source Data Table starting in Cell B2 (which is empty):
Source Data Table:
[TABLE="class: grid, width: 669"]
<tbody>[TR]
[TD] [Cell B2][/TD]
[TD]322-H7[/TD]
[TD]323-H7[/TD]
[TD]324-G8[/TD]
[TD]325-C11[/TD]
[TD]326-E10[/TD]
[TD]327-E10[/TD]
[/TR]
[TR]
[TD]Benzene[/TD]
[TD]0.00829 U[/TD]
[TD]0.00717 U[/TD]
[TD]0.00806 U[/TD]
[TD]0.0077 U[/TD]
[TD]0.0082 U[/TD]
[TD]0.00797 U[/TD]
[/TR]
[TR]
[TD]Toluene[/TD]
[TD]0.0237 U[/TD]
[TD]0.0205 U[/TD]
[TD]0.0231 U[/TD]
[TD]0.022 U[/TD]
[TD]0.0235 U[/TD]
[TD]0.0228 U[/TD]
[/TR]
[TR]
[TD]Ethylbenzene[/TD]
[TD]0.0297 U[/TD]
[TD]0.0257 U[/TD]
[TD]0.0288 U[/TD]
[TD]0.0276 U[/TD]
[TD]0.0293 U[/TD]
[TD]0.0285 U[/TD]
[/TR]
[TR]
[TD]mp-Xylene[/TD]
[TD]0.0593 U[/TD]
[TD]0.0513 U[/TD]
[TD]0.0577 U[/TD]
[TD]0.0551 U[/TD]
[TD]0.0587 U[/TD]
[TD]0.0571 U[/TD]
[/TR]
[TR]
[TD]o-Xylene[/TD]
[TD]0.0297 U[/TD]
[TD]0.0257 U[/TD]
[TD]0.0288 U[/TD]
[TD]0.0276 U[/TD]
[TD]0.0293 U[/TD]
[TD]0.0285 U[/TD]
[/TR]
[TR]
[TD]Gasoline[/TD]
[TD]5.93 U[/TD]
[TD]5.13 U[/TD]
[TD]5.77 U[/TD]
[TD]5.51 U[/TD]
[TD]5.87 U[/TD]
[TD]5.71 U[/TD]
[/TR]
</tbody>[/TABLE]
Smaller tables output, can start one row down from source table for spacing(Note the column header moves to the left in Column B):
[TABLE="class: grid, width: 204"]
<tbody>[TR]
[TD]322-H7[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Benzene[/TD]
[TD]0.00829 U[/TD]
[/TR]
[TR]
[TD]Toluene[/TD]
[TD]0.0237 U[/TD]
[/TR]
[TR]
[TD]Ethylbenzene[/TD]
[TD]0.0297 U[/TD]
[/TR]
[TR]
[TD]mp-Xylene[/TD]
[TD]0.0593 U[/TD]
[/TR]
[TR]
[TD]o-Xylene[/TD]
[TD]0.0297 U[/TD]
[/TR]
[TR]
[TD]Gasoline[/TD]
[TD]5.93 U[/TD]
[/TR]
</tbody>[/TABLE]
and so on..until entire Source Data Table has been split up.
Thoughts? Scripting.Dictionary? Not well versed in that complex coding, but have seen it work well on something similar, I just can get my head around tweaking the code I have to apply here.
Thanks! Russell
Trying to figure out how to take a table of data and split into individual smaller tables. The source data table columns and rows are variable, from a few columns/rows to quite a lot, so maybe a message box asking user to select Range?
or something like:
Dim c1 As Range
Dim c2 As Range
lastColumn = ActiveSheet.Cells(c1.Row, Columns.Count).End(xlToLeft).Column
For Each c2 In Range(Cells(c1.Row, 3), Cells(c1.Row, lastColumn)).
Start with User pasting the Source Data Table starting in Cell B2 (which is empty):
Source Data Table:
[TABLE="class: grid, width: 669"]
<tbody>[TR]
[TD] [Cell B2][/TD]
[TD]322-H7[/TD]
[TD]323-H7[/TD]
[TD]324-G8[/TD]
[TD]325-C11[/TD]
[TD]326-E10[/TD]
[TD]327-E10[/TD]
[/TR]
[TR]
[TD]Benzene[/TD]
[TD]0.00829 U[/TD]
[TD]0.00717 U[/TD]
[TD]0.00806 U[/TD]
[TD]0.0077 U[/TD]
[TD]0.0082 U[/TD]
[TD]0.00797 U[/TD]
[/TR]
[TR]
[TD]Toluene[/TD]
[TD]0.0237 U[/TD]
[TD]0.0205 U[/TD]
[TD]0.0231 U[/TD]
[TD]0.022 U[/TD]
[TD]0.0235 U[/TD]
[TD]0.0228 U[/TD]
[/TR]
[TR]
[TD]Ethylbenzene[/TD]
[TD]0.0297 U[/TD]
[TD]0.0257 U[/TD]
[TD]0.0288 U[/TD]
[TD]0.0276 U[/TD]
[TD]0.0293 U[/TD]
[TD]0.0285 U[/TD]
[/TR]
[TR]
[TD]mp-Xylene[/TD]
[TD]0.0593 U[/TD]
[TD]0.0513 U[/TD]
[TD]0.0577 U[/TD]
[TD]0.0551 U[/TD]
[TD]0.0587 U[/TD]
[TD]0.0571 U[/TD]
[/TR]
[TR]
[TD]o-Xylene[/TD]
[TD]0.0297 U[/TD]
[TD]0.0257 U[/TD]
[TD]0.0288 U[/TD]
[TD]0.0276 U[/TD]
[TD]0.0293 U[/TD]
[TD]0.0285 U[/TD]
[/TR]
[TR]
[TD]Gasoline[/TD]
[TD]5.93 U[/TD]
[TD]5.13 U[/TD]
[TD]5.77 U[/TD]
[TD]5.51 U[/TD]
[TD]5.87 U[/TD]
[TD]5.71 U[/TD]
[/TR]
</tbody>[/TABLE]
Smaller tables output, can start one row down from source table for spacing(Note the column header moves to the left in Column B):
[TABLE="class: grid, width: 204"]
<tbody>[TR]
[TD]322-H7[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Benzene[/TD]
[TD]0.00829 U[/TD]
[/TR]
[TR]
[TD]Toluene[/TD]
[TD]0.0237 U[/TD]
[/TR]
[TR]
[TD]Ethylbenzene[/TD]
[TD]0.0297 U[/TD]
[/TR]
[TR]
[TD]mp-Xylene[/TD]
[TD]0.0593 U[/TD]
[/TR]
[TR]
[TD]o-Xylene[/TD]
[TD]0.0297 U[/TD]
[/TR]
[TR]
[TD]Gasoline[/TD]
[TD]5.93 U[/TD]
[/TR]
</tbody>[/TABLE]
and so on..until entire Source Data Table has been split up.
Thoughts? Scripting.Dictionary? Not well versed in that complex coding, but have seen it work well on something similar, I just can get my head around tweaking the code I have to apply here.
Thanks! Russell