我正在尝试将单元格值从一个Excel工作表复制到另一个。为此我写了以下代码:
Dim p As Variant
For p = 2 To 12000
If ThisWorkbook.Sheets("Sheet1").Cells(p, 1).Value = ThisWorkbook.Sheets("Sheet2").Cells(p, 7).Value Then
Sheet1.Cells(p, 9).Value = Sheet2.Cells(p, 7).Value
End If
Next p
只有复制没有完成才进行比较......你能不能帮我解决这个问题。
提前致谢
答案 0 :(得分:0)
为什么不使用它:
ThisWorkbook.Sheets("Sheet1").Cells(p, 9).Value = ThisWorkbook.Sheets("Sheet2").Cells(p, 7).Value
答案 1 :(得分:0)
这对我有用:
Dim p As Long
For p = 2 To 12000
If ThisWorkbook.Sheets("Sheet1").Cells(p,1).Value = ThisWorkbook.Sheets("Sheet2").Cells(p,7).Value Then
ThisWorkbook.Sheets("Sheet1").Cells(p,9).Value = ThisWorkbook.Sheets("Sheet2").Cells(p,7).Value
End If
Next p