简体   繁体   English

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

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

I'm facing this issue i just want to enter the data in user form-text box and that value have to auto fill from the row to the last row of the column B. with this code i having error with range from active cell to the lastrow of the column.我正面临这个问题,我只想在用户表单文本框中输入数据,并且该值必须从行自动填充到 B 列的最后一行。使用此代码,我从活动单元格到范围有错误列的最后一行。 find the last line of the code range.kindly issue out this problem.找到代码范围的最后一行。请发出这个问题。

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

Is it just this that you need?你需要的只是这个吗? Not sure I fully understand.不确定我是否完全理解。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM