Fjott
Fjott

Reputation: 1137

Copy row and paste into multiple rows

I have the following code, that will copy a row and paste it into multiple rows.

For i = 2 To 100
    Rows(101).Copy Rows(i)
Next i

This does work, but it takes a lot of resources, because of the copying is made 100 times.

Is there a way to optimize this code, so that the copying can be made once in advanced, instead of 100-times inside the For-loop ?

Have tried this, but this does throw an error. "Object doesn't support this property or method"

Rows(101).Copy

For i = 2 To 100
     Rows(i)
Next i

Upvotes: 0

Views: 561

Answers (1)

Pᴇʜ
Pᴇʜ

Reputation: 57683

You can copy it in just one line to all rows:

Rows(101).Copy Rows("2:100")

Upvotes: 1

Related Questions