![]() ![]() Range("D1").Value = Columns("D:D").ColumnWidth I also reselect the cell that I originally had selected before running it. I want to preserve the original size of columns B+G and put a minimum column width of 17 on the resized C+H. In this I have many cells in columns B:C and G:H that I want to resize. Because the macro will change the active cell, I normally put in something at the end that restores the original cell selected. Either call this in your main macro or put it all in your main macro Next record another macro where you go one by one and remerge the cells. If you want them to be equal, set both equal to the autofitted column value/2.etc. For Example, if you want to preserve the size of the first column and only modify the width of the 2nd you would set the width of the second equal to the value of the autofitted column minus the width of the first column. The next step is figuring out how you want the resizing of both to be spaced. Next put in a bit of code that unmerges any cell selected. Either call this as a seperate macro or just cut and paste it into your main one. Next record a macro where you select the cells that are merged that you want to resize. Once this is there, hide the column autofitted column. For example if you want there to be a minimum or maximum column width for both columns on the resize, create it by using IF to modify the cell (D1) that has the autofitted column width's value. Now figure out how you want to resize the columns. Make a cell in this column equal to the Autofitted column's column width value(D1). Make the cell in this new column next to the merged cell group that you want to resize = to the merged cell's value.Īutofit this merged column(D). To the right of each merged group of cells, create a new column. This is based on resizing 2 columns, but you can apply it to more. This next one is for multiple merged cells across columns (not rows) and is a bit more complicated, but builds on the same thing. Activate the resize by autofitting the row height either in a macro or on the sheet itself. Simply create a cell next to the merged cell that has a formula that = the Merged Cell's Address. The first is the easier one, for minor applications. If things will look much better with merged cells though, I've developed a two workarounds. The short answer is avoid merged cells whenever possible. I realize that this hasn't been updated in forever, but I assume its a common problem. ![]()
0 Comments
Leave a Reply. |