以下代码假设将数据复制粘贴到不同的列中。例如,范围D5中的值被复制到列BV和CU中。代码运行良好,直到现在我收到错误
对象'Range'的方法'Value'失败
我已在互联网上查看其他人是否遇到了同样的错误问题。许多人认为可能是因为无限循环或Application.ScreenUpdating
必须设置为 False 。我做到了,但我仍然遇到了问题。
我非常喜欢这段代码的工作方式,因为复制粘贴特定范围的值非常快。可以请任何人帮我解决这个问题吗?
提前致谢!
Private Sub CommandButton3_Click()
Dim j As Long
For j = 1 To Range("d5, e5, h5, g5, r5, w5, ab5, ah5, ai5, aj5, ak5").End(xlDown).Row
Cells(j, "bv") = Cells(j, "d")
Cells(j, "cu") = Cells(j, "d")
Cells(j, "br") = Cells(j, "e")
Cells(j, "ay") = Cells(j, "e")
Cells(j, "cx") = Cells(j, "e")
Cells(j, "bf") = Cells(j, "g")
Cells(j, "bu") = Cells(j, "g")
Cells(j, "cr") = Cells(j, "g")
Cells(j, "dh") = Cells(j, "r")
Cells(j, "cv") = Cells(j, "w")
Cells(j, "bj") = Cells(j, "ab")
Cells(j, "dc") = Cells(j, "ah")
Cells(j, "dd") = Cells(j, "ai")
Cells(j, "bs") = Cells(j, "aj")
Cells(j, "ba") = Cells(j, "aj")
Cells(j, "cy") = Cells(j, "aj")
Cells(j, "bb") = Cells(j, "ak")
Cells(j, "bt") = Cells(j, "ak")
Cells(j, "cz") = Cells(j, "ak")
Next j
Application.ScreenUpdating = False
End Sub