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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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,225,738
Messages
6,186,725
Members
453,368
Latest member
positivemind

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