Добавьте .Row
в конец переменной LastRow2
и используйте метод Range.AutoFill , правильно:
SourceRange.Autofill Destination:=DestinationRange
, где DestinationRange
должен включать SourceRange
.
Я настоятельно рекомендую избегать использования Select .
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("B" & LastRow : "AA" & LastRow).Autofill Destination:=Range("B" & LastRow : "AA" & LastRow + 1)
'^ Note this must be LastRow not LastRow + 1!
Альтернатива:
Dim LastCell As Range
Set LastCell = Cells(Rows.Count, 2).End(xlUp) 'without .Row
LastCell.Resize(1, 26).AutoFill Destination:=LastCell.Resize(2, 26) '1 down
Альтернатива:
Dim SourceRange As Range
Set SourceRange = Cells(Rows.Count, 2).End(xlUp).Resize(1, 26) 'results in column B to AA
SourceRange.AutoFill Destination:=SourceRange.Resize(RowSize:=2) '1 down