我有以下vba代码给我一个错误消息。预期:表达

时间:2017-06-26 17:07:35

标签: excel-vba vba excel

尝试创建宏以动态使用自动填充功能。代码在最后一行失败: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

0 个答案:

没有答案