Good day! You need to write in the last filled line of the column "A" a certain value. Here this code writes in the current sheet, and I need in the specific. How to fix?

Dim ra As Range Set ra = Range("A" & Rows.Count).End(xlUp).Offset(1) ra = TextBox6.Value 
  • As an option, hung up on the Sheets button ("desired sheet"). Select, it works, but can there be a more accurate way? - lion295
  • To make a specific sheet, change the line. Set ra = Worksheets("нужный лист").Range("A" & Rows.Count).End(xlUp).Offset(1) You can even write this whole expression in one line: Worksheets("нужный лист").Range("A" & Rows.Count).End(xlUp).Offset(1) = TextBox6.Value - Eduard Izmalkov

2 answers 2

I figured it out myself

 ' Пишем в столбец А Dim ra As Range Set ra = Range("A" & Rows.Count).End(xlUp).Offset(1) ra = TextBox6.Value ' Пишем в столбец В Dim ra1 As Range Set ra1 = Range("A" & Rows.Count).End(xlUp).Offset(0, 1) ' с помощью Offset сдвигаем вниз на ноль, вправо на 1 ra1 = TextBox7.Value 
     Sub SaveRow() Dim lRws As Long With ActiveSheet ' заменить на нужный лист ' первая пустая (после заполненных) строка в столбце A lRws = .Cells(.Rows.Count, 1).End(xlUp).Row + 1 .Cells(lRws, 1).Value = TextBox6.Value ' запись в ячейку End With End Sub 

    Almost double the topic