Lymor
Lymor

Reputation: 1

Excel VBA - I need to paste a range of data down to the end the data of rows.

ie: I have data in E2:W2 and I'd like to paste it to E:W depending on how many rows there are in column A. Each time I run the macro it will be a different number of lines. It could be 3 or 2000 rows

Also, could be 1, so no copying necessary.

Upvotes: 0

Views: 412

Answers (1)

nutsch
nutsch

Reputation: 5962

Something like this will copy E2:W2 all the way down until there are no filled cells in column A

Sub CopyEW

if cells(rows.count,1).end(xlup).row>2 then _
    range("E2:W2").copy range("E2:W2").resize(cells(rows.count,1).end(xlup).row)

end if

end sub

Upvotes: 1

Related Questions