取消合并列时,过程过大

时间:2019-03-04 13:25:18

标签: excel vba

使用下面的代码行,我想取消两列(A,B)的合并,但是当我运行宏时,我遇到了一个“过程太大”的错误,因为我认为这里有重复的代码。请,我如何使此代码正常工作!我有6215行代码,这些代码具有相同的重复代码,就像所附的代码一样。谢谢

 Columns("A:B").Select
Range("A626").Activate
With Selection
    .HorizontalAlignment = xlGeneral
    .VerticalAlignment = xlTop
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlLTR
    .MergeCells = True
End With
With Selection
    .HorizontalAlignment = xlGeneral
    .VerticalAlignment = xlTop
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .MergeCells = True
End With
With Selection
    .HorizontalAlignment = xlGeneral
    .VerticalAlignment = xlTop
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .MergeCells = True
End With
With Selection
    .HorizontalAlignment = xlGeneral
    .VerticalAlignment = xlTop
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .MergeCells = True
End With
With Selection
  ..............

1 个答案:

答案 0 :(得分:0)

删除所有重复的代码,然后尝试这个。

Sub test()
    Range("A1:B626").UnMerge
    Columns(2).Delete
End Sub