1

我写了一些有效的代码,但速度很慢。

有人可以帮我将这十行丑陋的代码合并成一行优雅的代码吗?:

    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "A").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "B").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "C").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "D").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "E").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "F").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "G").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "H").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "I").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "J").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
4

1 回答 1

0

也许

Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "A").Resize(, 10).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
于 2013-07-26T13:34:29.897 回答