我需要复制C74 Cell
然后粘贴到C85到C88
条件 1:哪个单元格大于 0 无需粘贴
条件 2:哪个单元格为 0,然后粘贴 C74 值。
*无需粘贴到所有具有 0 的单元格
*只需将值粘贴到包含 0 的第一个单元格。
我尝试最多 2 个单元格。但我需要它最多 4 个单元格。
有谁指导我..
Sub TIMECALC()
ActiveSheet.Range("C74").Copy
If ActiveSheet.Range("C85").Value > 0 Then ActiveSheet.Range("C86").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False Else ActiveSheet.Range("C85").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
折断
使用For Each...
通过的范围内循环C85:C88
,做比较,如果这些细胞的值是如果为真大于0。然后粘贴C74含量/值。
Sub Calc()
'Copy the cell
Range("C74").Copy
'Loop through each cell of the range
For Each cell In Range("C85:C88")
If cell.Value = 0 Then
'Paste copied value
cell.PasteSpecial Paste:=xlPasteValues
'Exit the loop
Exit For
End If
Next
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句