Forum Discussion
Column width after Column Insert
Greetings.
Is there a way to insert a column between two columns and have the column widths adjust automatically?
For instance, Column A is 20 wide and Column B is 60 wide and Column C is 30 wide. If I insert a new column between A & B, I want the New column to be the default width, the new Column C (which was B) to maintain its width of 60, not change to 30.
In other words, is there a way to have column widths shift with their columns?
I realized shortly after I wrote this, that I was working with a Table and not a range. So when I tried to enter a new column, the Table prevented me from doing what I was trying to explain above. Sorry for the confusion.
2 Replies
- dolfinmagikproCopper Contributor
I realized shortly after I wrote this, that I was working with a Table and not a range. So when I tried to enter a new column, the Table prevented me from doing what I was trying to explain above. Sorry for the confusion.
How about automating
Sub InsertColumnPreserveWidth() Dim colIndex As Integer colIndex = ActiveCell.Column Dim originalWidth As Double originalWidth = Columns(colIndex + 1).ColumnWidth Columns(colIndex + 1).Insert Shift:=xlToRight Columns(colIndex + 2).ColumnWidth = originalWidth End Sub
by VBA: