Hi everybody,
A simple, yet impossible for me to figure out request. I found the below code that inserts rows based on the numeric value of the 8th column of a data set (with first row being headings) and also copies the data from the above rows in all inserted rows. However, I need a slight modification and I'm not able to figure out how to change the code. I need X-1 rows to be inserted instead of X. Would somebody provide me with the solution? Many thanks!
Sub RowsInsert()
Dim r As Long
For r = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
With Cells(r, 8)
If IsNumeric(.Value) And Not IsEmpty(.Value) Then
Rows(r + 1).Resize(.Value).Insert
Range(Replace("A#:AC#", "#", r)).Copy Destination:=Range("A" & r + 1).Resize(.Value)
End If
End With
Next r
End Sub
A simple, yet impossible for me to figure out request. I found the below code that inserts rows based on the numeric value of the 8th column of a data set (with first row being headings) and also copies the data from the above rows in all inserted rows. However, I need a slight modification and I'm not able to figure out how to change the code. I need X-1 rows to be inserted instead of X. Would somebody provide me with the solution? Many thanks!
Sub RowsInsert()
Dim r As Long
For r = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
With Cells(r, 8)
If IsNumeric(.Value) And Not IsEmpty(.Value) Then
Rows(r + 1).Resize(.Value).Insert
Range(Replace("A#:AC#", "#", r)).Copy Destination:=Range("A" & r + 1).Resize(.Value)
End If
End With
Next r
End Sub