I need to modify this code, or if one could write me one which would be more efficient.
Not This formula works great, but I need the new row to insert only in column A to F.
The reason being, I have data/report table from H3 to K36 which needs to stay and cannot be modified with new rows.
Sub InsertRow()
If ActiveCell.Column = 1 Then
Dim numCopies As Long
numCopies = 1
Dim i As Long
For i = 1 To numCopies
Rows(ActiveCell.Row + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next i
ActiveCell.AutoFill Destination:=Range(ActiveCell, ActiveCell.Offset(numCopies, 0)), Type:=xlFillDefault
End If
End Sub
Modify and try one of the below:
Option Explicit
Sub test()
With ThisWorkbook.Worksheets("Sheet1")
.Range("A1").EntireRow.Insert ' <- Insert a row at row 1
.Rows("1:3").EntireRow.Insert ' <- Insert 3 rows from 1
End With
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.