mtach - copy entire row from 1 sheet to another

oddworld

Active Member
Joined
May 31, 2005
Messages
250
Hi all, i have trolled through a number of posts, i can't find an a match for what i am looking for.

I have 1 workbook with 2 sheets, I would like some advice on a macro to copy rows of data from sheet 1 that *are not listed in sheet2, and copy them to sheet 3. Unique values are in column "bn" on each sheet.

any assistance would be appreciated, need to sort this out
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hello Oddworld,

Here's an option:-


Code:
Sub Test()

         Dim fValue As Range
         Dim c As Range
         Dim lr As Long: lr = Sheet1.Range("BN" & Rows.Count).End(xlUp).Row

Application.ScreenUpdating = False

         Sheet3.UsedRange.ClearContents
         Sheet1.UsedRange.Copy Sheet1.[HA1]

For Each c In Sheet1.Range("BN2:BN" & lr)
         Set fValue = Sheet2.Columns("BN:BN").Find(c.Value)
         If fValue Is Nothing Then GoTo Nextval
         If c.Value = fValue.Value Then
         Range(c, c.Offset(, -65)).ClearContents
    End If
Nextval:
         If c.Value <> "" Then
         Range(c, c.Offset(, -65)).Copy Sheet3.Range("A" & Rows.Count).End(3)(2)
    End If
Next c

        Sheet1.[HA1].CurrentRegion.Copy Sheet1.[A1]
        Sheet1.[HA1].CurrentRegion.Clear
        Sheet3.Select

Application.ScreenUpdating = True

End Sub

I'm assuming that your data columns are from A:BN with all three sheets having headings in Row1.
The code also temporarily uses helper columns from HA and beyond.

I hope that this helps.

Cheerio,
vcoolio.

P.S. I'm also assuming that all data will remain in sheets 1 and 2.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,747
Messages
6,180,719
Members
452,995
Latest member
isldboy

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