Merge a number of cells based on a numeric value in 3rd cell

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:
Segment1
Market Share1
Segment2
Market Share2
Firm1
0%
Firm1
30%
Firm2
20%
Firm2
10%
Firm3
10%
Firm3
0%
Firm4
10%
Firm4
0%
Firm5
50%
Firm5
0%
Firm6
0%
Firm6
30%
Firm7
10%
Firm7
30%
Segment1
Segment2
100 lines
100 lines

<tbody>
</tbody>

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? :confused:

Thanks a lot in advance!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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