Excel vba移动列并保留宽度

我有代码来左右移动列根据按键,但列宽不保留,因为我移动的列。 我想要移动的列保留其宽度,移动的列也保留其宽度。

Public Sub moveColumnleft() ActiveCell.EntireColumn.Select Selection.EntireColumn.Cut If ActiveCell.Column = 1 Then Exit Sub ActiveCell.offset(0, -1).Insert Shift:=xlLeft ActiveCell.offset(0, -1).Select End Sub Public Sub moveColumnRight() ActiveCell.EntireColumn.Select Selection.EntireColumn.Cut ActiveCell.offset(0, 2).Insert Shift:=xlRight ActiveCell.offset(0, 1).Select End Sub 

存储移动的列与我一起工作(Excel 2007)。 看下面的代码

 Public Sub moveColumnleft() ActiveCell.EntireColumn.Select Selection.EntireColumn.Cut '' store column width in variable **tmp** Dim tmp As Double tmp = ActiveCell.EntireColumn.ColumnWidth If ActiveCell.Column = 1 Then Exit Sub ActiveCell.Offset(0, -1).Insert Shift:=xlLeft ActiveCell.Offset(0, -1).Select '' apply the stored width to the moved column Range(ActiveCell.Address).ColumnWidth = tmp End Sub