L
Legacy 223018
Guest
Hi there,
I'm trying something new to me in Excel using VBA:
The base of data is a table with a fixed number of market segments. For each segment there is the same list of competitors (text values). The length of the list may vary as it is created by another macro. Associated to each segment there is the market share per competitor (numeric values). The total of each market share column is always 100%.
The second part of the worksheet is a range of exactly 100 empty lines pre-formatted into very low row height (3.0).
Here the example:
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]Segment1
[/TD]
[TD]Market Share1
[/TD]
[TD]Segment2
[/TD]
[TD]Market Share2
[/TD]
[/TR]
[TR]
[TD]Firm1
[/TD]
[TD]0%
[/TD]
[TD]Firm1
[/TD]
[TD]30%
[/TD]
[/TR]
[TR]
[TD]Firm2
[/TD]
[TD]20%
[/TD]
[TD]Firm2
[/TD]
[TD]10%
[/TD]
[/TR]
[TR]
[TD]Firm3
[/TD]
[TD]10%
[/TD]
[TD]Firm3
[/TD]
[TD]0%
[/TD]
[/TR]
[TR]
[TD]Firm4
[/TD]
[TD]10%
[/TD]
[TD]Firm4
[/TD]
[TD]0%
[/TD]
[/TR]
[TR]
[TD]Firm5
[/TD]
[TD]50%
[/TD]
[TD]Firm5
[/TD]
[TD]0%
[/TD]
[/TR]
[TR]
[TD]Firm6
[/TD]
[TD]0%
[/TD]
[TD]Firm6
[/TD]
[TD]30%
[/TD]
[/TR]
[TR]
[TD]Firm7
[/TD]
[TD]10%
[/TD]
[TD]Firm7
[/TD]
[TD]30%
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Segment1
[/TD]
[TD][/TD]
[TD]Segment2
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]100 lines
[/TD]
[TD][/TD]
[TD]100 lines
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
What I would like to do with this:
For each per cent of market share I would like to assign 1 line in the second part of the worksheet to a competitor. For example, for a competitor's market share in segment 1 of 10% I would need to assign 10 cells to the competitor in the to be created table below and merge them into one. In this part of the worksheet column B has no function. In column C this same procedure will have to be done for segment 2.
After merging the cells into the newly created single one, the latter should contain the text value which is the name of the firm x and its market share in %. Obviously only cells that have not been merged, yet, should be considered. At the end all 100 lines should have been treated by the macro.
The whole thing in theory corresponds to the automatic creation of a 100% stacked column chart but for company internal reasons related to how I present the data, I cannot use that chart type.
As of now I have only (in my opinion) useless bits of code. So I won't post it here. What I have particular problems with is to imagine how I can use a numeric value x, then to select a range of cells y (where x = y) and merge them.
Any ideas how to get me started?
Thanks a lot in advance!
I'm trying something new to me in Excel using VBA:
The base of data is a table with a fixed number of market segments. For each segment there is the same list of competitors (text values). The length of the list may vary as it is created by another macro. Associated to each segment there is the market share per competitor (numeric values). The total of each market share column is always 100%.
The second part of the worksheet is a range of exactly 100 empty lines pre-formatted into very low row height (3.0).
Here the example:
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]Segment1
[/TD]
[TD]Market Share1
[/TD]
[TD]Segment2
[/TD]
[TD]Market Share2
[/TD]
[/TR]
[TR]
[TD]Firm1
[/TD]
[TD]0%
[/TD]
[TD]Firm1
[/TD]
[TD]30%
[/TD]
[/TR]
[TR]
[TD]Firm2
[/TD]
[TD]20%
[/TD]
[TD]Firm2
[/TD]
[TD]10%
[/TD]
[/TR]
[TR]
[TD]Firm3
[/TD]
[TD]10%
[/TD]
[TD]Firm3
[/TD]
[TD]0%
[/TD]
[/TR]
[TR]
[TD]Firm4
[/TD]
[TD]10%
[/TD]
[TD]Firm4
[/TD]
[TD]0%
[/TD]
[/TR]
[TR]
[TD]Firm5
[/TD]
[TD]50%
[/TD]
[TD]Firm5
[/TD]
[TD]0%
[/TD]
[/TR]
[TR]
[TD]Firm6
[/TD]
[TD]0%
[/TD]
[TD]Firm6
[/TD]
[TD]30%
[/TD]
[/TR]
[TR]
[TD]Firm7
[/TD]
[TD]10%
[/TD]
[TD]Firm7
[/TD]
[TD]30%
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Segment1
[/TD]
[TD][/TD]
[TD]Segment2
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]100 lines
[/TD]
[TD][/TD]
[TD]100 lines
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
What I would like to do with this:
For each per cent of market share I would like to assign 1 line in the second part of the worksheet to a competitor. For example, for a competitor's market share in segment 1 of 10% I would need to assign 10 cells to the competitor in the to be created table below and merge them into one. In this part of the worksheet column B has no function. In column C this same procedure will have to be done for segment 2.
After merging the cells into the newly created single one, the latter should contain the text value which is the name of the firm x and its market share in %. Obviously only cells that have not been merged, yet, should be considered. At the end all 100 lines should have been treated by the macro.
The whole thing in theory corresponds to the automatic creation of a 100% stacked column chart but for company internal reasons related to how I present the data, I cannot use that chart type.
As of now I have only (in my opinion) useless bits of code. So I won't post it here. What I have particular problems with is to imagine how I can use a numeric value x, then to select a range of cells y (where x = y) and merge them.
Any ideas how to get me started?
Thanks a lot in advance!