【发布时间】:2015-05-16 19:30:21
【问题描述】:
Sub abc()
Dim lrow As Long
Dim ws As Worksheet
Set ws = ActivsheetWorksheets("Completed")
Dim strFormulas(1 To 3) As Variant
lrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
With ws
.Range("Y2:Z" & lrow).FillDown
End With
With ThisWorkbook.Sheets("Completed")
strFormulas(1) = "=(N2-A2)+(R2-O2)+(V2-S2)"
strFormulas(2) = "=IFERROR(Y2/L2,Y2)"
.Range("Y2:Z2").Formula = strFormulas
End With
End Sub
Sub bcd()
Dim lrow As Long
Dim ws As Worksheet
Set ws = Worksheets("Follow-up")
Dim strFormulas(1 To 3) As Variant
lrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
With ws
.Range("Y2:Z" & lrow).FillDown
End With
With ThisWorkbook.Sheets("Follow-up")
strFormulas(1) = "=(N2-A2)+(R2-O2)+(V2-S2)"
strFormulas(2) = "=IFERROR(Y2/L2,Y2)"
.Range("Y2:Z2").Formula = strFormulas
End With
End Sub
上面的代码可以简化为一个吗?它工作正常,但问题是我需要简化代码,因为我必须在 UserForm 中调用它。提前致谢。
【问题讨论】:
-
你只想把它们放在一个子里吗?
-
Paul,代码似乎没有任何更改。你能告诉我具体的变化是什么吗..
-
是的,保罗,我希望它在一个子之下。