Copying unique range pastes column 7 twice

javifais

New Member
Joined
Dec 14, 2015
Messages
28
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: 23
  • MODIFIED_data.PNG
    MODIFIED_data.PNG
    13 KB · Views: 24

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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