VBA - xlFilterCopy/CopyToRange - Paste Special to retain destination formatting?

BPW

New Member
Joined
Mar 7, 2013
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I'm stuck and need a little guidance. I'm attempting to copy unique values within a column of one worksheet and paste them within another worksheet (same workbook) retaining the destination sheet's formatting. Below is the VBA that pastes over the formatting.

VBA Code:
Sub CreateUniqueList2()
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = Worksheets("Data Dump")
Set ws2 = Worksheets("rollups")

Dim lastrow As Long

lastrow = Cells(Rows.Count, "B").End(xlUp).Row


ws1.Activate

ws1.Range("B3:B" & lastrow).AdvancedFilter _
    Action:=xlFilterCopy, _
    CopyToRange:=ws2.Range("b4"), _
    Unique:=True
     
End Sub

Thanks in advance!
BPW
 
Glad we could help & thanks for the feedback.
Hi Fluff, any chance you can help on some of my posts? I have some working code, but just need to have it modified a bit but dont know how.
Thank-you,
Yellow
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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