中的同一行
我的代码在所有H2列中粘贴了相同的公式。我看不到代码中的任何地方。
Worksheets("sheet1").Activate
Range("F2").Activate
Do Until IsEmpty(ActiveCell)
If ActiveCell.Value <> "" Then
Pickle = ActiveCell.Address
ActiveCell.Offset(0, 2).Select
ActiveCell.Value = "=IF(" + Pickle + " <TODAY(),""Send Reminder"",""Do not Send Reminder"") "
ActiveCell.Offset(0, -2).Select
End If
ActiveCell.Offset(1, 0).Select
Loop
无需循环。使用.FormulaR1C1
不要使用激活并选择,它们会减慢代码
Dim lastrow As Long
With Worksheets("sheet1")
lastrow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("H2:H" & lastrow).FormulaR1C1 = "=IF(RC[-2] <TODAY(),""Send Reminder"",""Do not Send Reminder"") "
End With
这立即将公式放入所有单元格中,并且RC [-2]正确地指列f