Copying unique range pastes column 7 twice

javifais

New Member
Joined
Dec 14, 2015
Messages
23
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a code to copy columns A:L. Paste the unique rows to columns O:Z. Somehow, the code is overwriting column W with values from column G.
Here is the code:
VBA Code:
Sub oneUserPerRow()
Dim lastCol As Long, lastRow As Long, r As Long, i As Long
Dim Rng As Range, Rng1 As Range, Rng2 As Range, Rng3 As Range
'Application.ScreenUpdating = False
With Sheets("Sheet1")
    Set Rng = .UsedRange
    Set Rng1 = Intersect(Rng, .Range("A:A"))
    lastCol = Rng.Column + Rng.Columns.Count - 1
    .Range("A:L").AdvancedFilter Action:=xlFilterCopy, _
    CopyToRange:=.Cells(1, lastCol + 2), Unique:=True
    
     Columns("O:Z").Copy Destination:=Sheets("Employee Sheet").Columns("A:L")
    'Columns("O:Z").EntireColumn.Delete
End With
[/CODE
][ATTACH type="full"]70759[/ATTACH][ATTACH type="full"]70760[/ATTACH]
 

Attachments

  • ORIG_DATA.PNG
    ORIG_DATA.PNG
    28.6 KB · Views: 4
  • MODIFIED_data.PNG
    MODIFIED_data.PNG
    13 KB · Views: 4

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

javifais

New Member
Joined
Dec 14, 2015
Messages
23
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I resolved the issue myself. The issue was that I had two columns named the same way. I modified the header for column 7 to read 'DESCR2' so that it doesn't match another column header.
 
Solution

Forum statistics

Threads
1,176,242
Messages
5,902,103
Members
434,940
Latest member
Suresh877

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
Top