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

boerner

New Member
Joined
Aug 8, 2012
Messages
6
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!
 

Forum statistics

Threads
1,081,676
Messages
5,360,441
Members
400,586
Latest member
Minty

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top