我写了一些有用的代码但很慢。
有人可以帮我把这十行难看的代码合并成一个优雅的行吗?:
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
答案 0 :(得分:0)
也许
Worksheets(Cells(x, "P").Value).Cells(Cells(x, "Q").Value, "A").Resize(, 10).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove