我正在寻找有关我的代码的帮助。我想遍历多个工作表并将第一行中的公式复制到最后一行,行依赖于该月的日期。 这是我的代码示例;
Sub RECON_CALC2()
Dim sheet As Worksheet, Last As Long, rng As Range
Application.ScreenUpdating = False
Windows("testbook.xlsx").activate
For Each sheet In ActiveWorkbook.Worksheets
If sheet.Index > 3 Then
Last = Range("B3").End(xlDown).row
Sheet.Range("F3") = "=VLOOKUP(R[-2]C[-1],'CLIENT YLD'!C1:C8,4,0)"
Sheet.Range("E3:T3").Copy
Sheet.Range("E3:T" & Last).Copy Destination:=sheet.Range("E3:T" & Last)
Sheet.Columns("R:T").NumberFormat = "0.000000"
Sheet.Columns("A:T").EntireColumn.AutoFit
End If
Next
MsgBox "RECON COMPLETE"
Windows("Macro.xlsm").activate
Application.ScreenUpdating = True
End Sub
代码适用于所有工作表,但范围错误。