1
我寫了一些可以正常工作的代碼,但速度很慢。將10行代碼合併到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
你知道有一個[代碼審查(HTTP:/ /codereview.stackexchange.com/?as=1)SE上的網站? – pnuts
我不知道。非常感謝! –