VBA for merging cells (both horizontally and vertically)

vlado89

New Member
Joined
May 29, 2019
Messages
1
Hello there!

Some time ago I found 2 VBA code blocks on the internet that allow me to do the following:
* automatically merge all cells with the same value in the active worksheet
* automatically unmerge all merged cells in the active worksheet without data loss (the original value of the merge cell is being copied to all unmerged cells - as a result I do not have any blank cells)

The problem is that the above code works only on row level (horizontally), and I need it in both directions (horizontally and vertically).
I will try to illustrate with 2 examples:

Current situation:
https://imgur.com/v7e3M7q

Desired logic:
https://imgur.com/ULfDs3y


Is it possible to achieve the desired logic through VBA coding?



Kind regards,
Vladimir
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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