通过将活动单元格的范围提供给列的最后一行来显示自动填充命令范围中的错误

Showing Error in Range of Auto fill command by giving range of Active cell to Last row of the column

我遇到了这个问题,我只想在用户表单文本框中输入数据,并且该值必须自动填充从行到列 B 的最后一行。使用此代码我遇到了错误范围从活动单元格到列的最后一行。找到代码的最后一行 range.kindly 解决这个问题。

Private Sub CommandButton2_Click()

Dim irow As Long
Dim activeworksheet As Worksheet
Dim lastrow As Long


    irow = ActiveWorkbook.Worksheets("Master sheet").Cells(Rows.Count, 1).End(xlUp).Row + 1

    lastrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row

    Set activeworksheet = ThisWorkbook.Worksheets("master sheet")

    With activeworksheet

    .Cells(irow, 1) = UserForm1.TextBox1.Value

    .Cells(irow, 1).Select

    Selection.range(range("Activecell"), range("A" & Cells(Rows.Count, "B").End(xlUp).Row)).FillDown


    End With

End Sub

您只需要这个吗?不确定我是否完全理解。

With activeworksheet
    Range(.Cells(irow, 1), .Cells(lastrow, 1)).Value = UserForm1.TextBox1.Value
End With