Copy and paste row many times by cell value by VBA

knaabis

Active Member
Joined
Apr 25, 2006
Messages
254
Office Version
  1. 2013
Platform
  1. Windows
I has simple code like this:
Sub InsertRow()
lastrow = Range("a1").End(xlDown).Row
irow = 2
Do Until irow > lastrow
If Cells(irow, 25).Value = 0.5 Then
Rows(irow + 1).Insert
End If
irow = irow + 1
Loop
End Sub

Need to change the code to, for example: "If Cells (irow, 25) .Value = 3 Then
this row needs to be copied and paste 3 times.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi
Try
VBA Code:
Sub InsertRow()
    lastrow = Range("a1").End(xlDown).Row
    irow = lastrow
    Do Until irow = 0
        If Cells(irow, 25).Value = 3 Then
            Rows(irow).EntireRow.Copy
      Rows(irow + 1).Resize(3).Insert Shift:=xlDown
        End If
        irow = irow - 1
    Loop
End Sub
 
Upvote 0
Solution
You are very welcome
And thank you for the feedback
Be happy and safe
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top