我写了一些有效的代码,但速度很慢。
有人可以帮我将这十行丑陋的代码合并成一行优雅的代码吗?:
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