Multiple Range Copy

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
Hi - I have this code to copy rows to another sheet. I thought I could extend the range by add this code. But no, any suggestions on how I include the extra columns in the copy range?

Tried this
Code:
ws1.Range((ws1.Cells(thisRowA, "B"), ws1.Cells(thisRowA, "H")), (ws1.Cells(thisRowA, "K"), ws1.Cells(thisRowA, "O"))).Copy


Code:
Do While thisRowA <= lastRowA    
foundRow = Application.Match(ws1.Cells(thisRowA, "B").Value, ws2.Range("A:A"), 0)
    If IsError(foundRow) Then
        thisRowA = thisRowA + 1
    Else
        ws1.Range(ws1.Cells(thisRowA, "B"), ws1.Cells(thisRowA, "H").Copy
        ws3.Cells(nextRowA, "A").PasteSpecial Paste:=xlPasteValues
        nextRow = nextRow + 1
        ws1.Range(ws1.Cells(thisRowA, "B"), ws1.Cells(thisRowA, "O")).ClearContents 
        lastRowA = lastRowA - 1
    End If
Loop
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
How about
Code:
Intersect(ws1.Rows(thisRowA), Union(ws1.Range("B:H"), ws1.Range("K:O"))).Copy
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,182
Members
448,948
Latest member
spamiki

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