VBA Copy data from filtered table to another worksheet but keep some columns of original?

Melimob

Active Member
Joined
Oct 16, 2011
Messages
395
Office Version
  1. 365
HI

I have a table example below

ClientNo. of acountsControl ClientsProduct1Product 2Product 3Proposed ProductProposed Product
code adds(formula)(formula)(formula)(formula)(Formula)(user selects)(user writes text)
Test11YesNoneYesYes
Test21YesNoneYesYes

<colgroup><col width="64" span="8" style="width:48pt"> </colgroup><tbody>
</tbody>

At the moment, upon any update on another tab, it's replacing column A (client list) which is fine since C-F are formulas so will read column A and update.
HOWEVER
columns G-H user may have already inputted so I need it to keep those values according to the client listed in column A

and then sort by Column A (A-Z)

Here's my original code:
Code:
Sub TechFootPrint()
UnProtect
RemoveFilters1a




Dim TFtPrint As Worksheet
Dim ABC As Worksheet
Dim copyRange As Range
Dim lastrow As Long


Application.ScreenUpdating = False


Set ABC = Sheets("ABC Clients ")
Set TFtPrint = Sheets("Tech FootPrint")


ABC.Range("B3").ListObject.ShowTotals = False
TFtPrint.Range("B5").ListObject.ShowTotals = False


With Sheets("Tech FootPrint")
.Range("Table16[Client]").ClearContents
End With


   
ABC.ListObjects("Table6").Range.AutoFilter Field:=4, Criteria1:= _
        "<>*Lost*", Operator:=xlAnd, Criteria2:="<>*OOS*"


ABC.Range("Table6[[ABC Client]]").SpecialCells(xlCellTypeVisible).Copy


TFtPrint.Range("B5").PasteSpecial xlPasteValues
    Application.CutCopyMode = False






    With ActiveWorkbook.Worksheets("Tech FootPrint")
        
        lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
        .Sort.SortFields.Clear


        .Sort.SortFields.Add Key:=.Range("B5").Resize(lastrow - 3), _
                             SortOn:=xlSortOnValues, _
                             Order:=xlAscending, _
                             DataOption:=xlSortNormal
        .Sort.SetRange .Range("B5").Resize(lastrow - 3)
        .Sort.Header = xlNo
        .Sort.MatchCase = False
        .Sort.Orientation = xlTopToBottom
        .Sort.SortMethod = xlPinYin
        .Sort.Apply
    End With


RemoveFilters1a


ABC.Range("B3").ListObject.ShowTotals = True
TFtPrint.Range("B5").ListObject.ShowTotals = True


Protect


End Sub

Am really grateful for anyone who can help me do this as I am at a loss?

many thanks
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,432
Messages
6,124,859
Members
449,194
Latest member
HellScout

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