0
当我尝试运行此循环时,我在Cell.Value.Copy
行中得到一个Error:Object Required。我需要做什么来解决这个错误?通过Loop-VBA复制单元格
Sub Findings()
Application.ScreenUpdating = False
Dim Cell As Object
Dim Rng As Range
Set Rng = Sheets("Sheet1").Range("C5:C74")
For Each Cell In Rng
If (Cell.Value <> "") Then
Cell.Value.Copy
End If
Next Cell
If IsEmpty(Range("C85").Value) = True Then
Range("C85").PasteSpecial xlPasteValues
ElseIf IsEmpty(Range("C86").Value) = True Then
Range("C86").PasteSpecial xlPasteValues
ElseIf IsEmpty(Range("C87").Value) = True Then
Range("C87").PasteSpecial xlPasteValues
End If
Application.ScreenUpdating = True
End Sub
只需使用'Cell.Copy'。 – Phylogenesis
因为随后的循环通过循环覆盖剪贴板中的值,所以开始“For Each Cell In Rng”的循环有点没有意义。在VBA中,使用复制/粘贴来传输值几乎没有什么好的理由 - 直接分配给目标范围的'.Value'。 –
@ gg315你是否在下面的答案中试过了代码? –