I'm attempting to insert a number of rows in a worksheet based on the number of data rows in another sheet, starting from the first empty row in my insert worksheet.
I can't find the right code to do it. Here is what I have right now
Any advice?
I can't find the right code to do it. Here is what I have right now
VBA Code:
Sub InsertRows()
Dim ws As Worksheet, sh As Worksheet
Dim strow As Long, nrow As Long
Dim i As Long
Set ws = ThisWorkbook.Worksheets("Test FAR")
Set sh = ThisWorkbook.Worksheets("Additions")
With ws
strow = ws.Range("A2").End(xlDown).Row + 1 'finds row to start inserting from
End With
With sh
nrow = [Counta(Additions!B:B)] - 1 'number of rows to insert
End With
For i = 1 To nrow
ws.Range(strow & i).EntireRow.Insert
Next i
End Sub