尝试创建宏以动态使用自动填充功能。代码在最后一行失败:Selection.AutoFill Destination:= Range(& SelectionAddress:& endCellToFill)。错误消息:expected:expression
Sub formulas()
Dim LastRow As Long
Dim SelectionAddress As String
Dim endCellToFill As String
Range("A2").Select
selectionColumn = Selection.Column
selectionRow = Selection.Row
SelectionAddress = Cells(selectionRow, selectionColumn).Address 'A2
LastRow = Cells(Rows.Count, selectionColumn + 1).End(xlUp).Row 'last row of the adjacent column to the right
endCellToFill = Cells(LastRow, selectionColumn).Address 'A19999
Selection.AutoFill Destination:=Range(&SelectionAddress:&endCellToFill)
End Sub