Hơw can I copy special range then paste to another sheet

sbv1986

Board Regular
Joined
Nov 2, 2017
Messages
87
Hi all:

I have wb copydata.xlsm with sheet("source","des")

In sheets("source") I want copy multiple ranges from row i (i = 1 to lastrow) that:
If cells(i,21)<>0 then
Copy range("Ai:Di") and range("Ui: last column) to sheets("des")

Please help me to do that with VBA, I have over 1.000 rows have to do. Thanks./.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Re: Hơ can I copy special range then paste to aonther sheet

Maybe this

Code:
Sub MM1()
Dim lr As Long, r As Long, lr2 As Long
lr = Cells(Rows.Count, "U").End(xlUp).Row
lr2 = Sheets("des").Cells(Rows.Count, "A").End(xlUp).Row
For r = 1 To lr
    If Cells(r, 21).Value <> 0 Then
        Range("A" & r & ":D" & r).Copy Sheets("des").Range("A" & lr2 + 1)
        lr2 = Sheets("des").Cells(Rows.Count, "A").End(xlUp).Row
    End If
Next r
End Sub
 
Upvote 0
Re: Hơ can I copy special range then paste to aonther sheet

Many thanks @Michael M :

But I thinks this code dulicate line:
lr2 = Sheets("des").Cells(Rows.Count, "A").End(xlUp).Row

How about range(Ui:lastcolumn), I want this range copy the same time with range(Ai:Di).

Could you please help me one again?
 
Upvote 0
Re: Hơ can I copy special range then paste to aonther sheet

Sorry I'm a bit confused ???
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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