Reputation: 3
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. 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
Upvotes: 0
Views: 39
Reputation: 23081
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
Upvotes: 0