View Full Version : Solved: Merge Cell Autofit (

02-15-2006, 07:26 AM
This thread was marked solved and it still has a problem. The code does what it is supposed to do, but when you tab out of the cell it takes you to the palceholder which is out in no man's land. Once the macro has run the only way to get it back is to hit enter twice??? OR to use the mouse. Would setting up a tab order fix this or would it just screw up the other macro?

That is a tough question! Autofit doesn't work on merged cells unfortunately. Luckily, a workaround has been created by Brad Yundt (byundt). Take a look at his solution here:
I have used this in the past, and works exactly as desired.

One thing you might want to do is get rid of those merged cells! They confuse VBA to no end, and just have more trouble than they're worth a lot of the time. You might want to take a look at the "Center across selection" option for Horizontal Alignment of a cell.
To use this, just to give you a quick example, create a new sheet and select cells A1:C1. Go to Format / Cells, then the Alignment tab, and change the horizontal alignment to 'center across selection'. Click ok. Now, in A1, type something. It is centered across those cells, even though they're not merged. It won't help you in this autofit issue, but it does alleviate a lot of the other problems that stem from merged cells.


02-15-2006, 07:45 AM
Hi cleturno,

FYI, I have emailed Brad/Byundt regarding this question. Hopefully he can stop by here to help, or someone else can help you.

As an FYI for everyone, the quoted text above is from http://www.vbaexpress.com/forum/showthread.php?t=6072 :)


02-15-2006, 07:49 AM
I was unaware that an E-mail had been sent thank you for the update.