Count Merged Cells

rsbuzatto

Board Regular
Joined
Mar 19, 2012
Messages
70
Hello folks!

I have the following "table" in my sheet and I'm in trouble to find a way of a code for what I need...

exceltable.jpg


Basically, my code must be able to identify my merged cells and, according to my product's name, fill my column 1. For example:

My first product is XXX and, for XXX I've defined the value 15, so this value (15) must be filled in the same rows that my XXX product are merged (same structure must happen to my second product and so on...).

PS: Those merged cells are variable, so, today I can merge 10 cells for first product and the rest of them for the second product... and tomorrow I can change thouse merged cells and so on...

However, I couldn't find a way to write this code (identifying my merged cells and fill my column according to it).

Is there any help from you guys?

Thanks in advance for any help and sorry if I'm not clear enough...


Cheers,
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Ill take a stab at it, but i need to know where the 15 is supposed to end up.
 
Upvote 0
Ill take a stab at it, but i need to know where the 15 is supposed to end up.

It supposes to end up where the merged area of the product's name ends. That's why I'm in trouble with...

So... in this example, my 15 value must be written in the red area!

Yet, my value column will be variable according to my merged cell... if my merged cell is 4 rows, my value must be written in those 4 rows and so on...


Thanks dude... hope you understand better now...
 
Last edited:
Upvote 0
maybe something like:
Code:
Sub test()
    Dim rngValue As Range
    Dim MergeRow As Long
    Set rngValue = ActiveCell
    MergeRow = Cells(rngValue.Row, 1).MergeArea.Rows.Count
    rngValue.Resize(MergeRow, 1).FillDown
End Sub
 
Upvote 0

Forum statistics

Threads
1,207,096
Messages
6,076,554
Members
446,213
Latest member
bettigb

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