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

Melimob

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

I have a table example below

[TABLE="width: 512"]
<colgroup><col width="64" span="8" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl7086, width: 64"]Client[/TD]
[TD="class: xl7086, width: 64"]No. of acounts[/TD]
[TD="class: xl7086, width: 64"]Control Clients[/TD]
[TD="class: xl7086, width: 64"]Product1[/TD]
[TD="class: xl7086, width: 64"]Product 2[/TD]
[TD="class: xl7086, width: 64"]Product 3[/TD]
[TD="class: xl7086, width: 64"]Proposed Product[/TD]
[TD="class: xl7086, width: 64"]Proposed Product[/TD]
[/TR]
[TR]
[TD="class: xl7086, width: 64"]code adds[/TD]
[TD="class: xl7086, width: 64"](formula)[/TD]
[TD="class: xl7086, width: 64"](formula)[/TD]
[TD="class: xl7086, width: 64"](formula)[/TD]
[TD="class: xl7086, width: 64"](formula)[/TD]
[TD="class: xl7086, width: 64"](Formula)[/TD]
[TD="class: xl7086, width: 64"](user selects)[/TD]
[TD="class: xl7086, width: 64"](user writes text)[/TD]
[/TR]
[TR]
[TD="class: xl7086, width: 64"]Test1[/TD]
[TD="class: xl7086, width: 64, align: right"]1[/TD]
[TD="class: xl7086, width: 64"]Yes[/TD]
[TD="class: xl7086, width: 64"]None[/TD]
[TD="class: xl7086, width: 64"]Yes[/TD]
[TD="class: xl7086, width: 64"]Yes[/TD]
[TD="class: xl7086, width: 64"] [/TD]
[TD="class: xl7086, width: 64"] [/TD]
[/TR]
[TR]
[TD="class: xl7086, width: 64"]Test2[/TD]
[TD="class: xl7086, width: 64, align: right"]1[/TD]
[TD="class: xl7086, width: 64"]Yes[/TD]
[TD="class: xl7086, width: 64"]None[/TD]
[TD="class: xl7086, width: 64"]Yes[/TD]
[TD="class: xl7086, width: 64"]Yes[/TD]
[TD="class: xl7086, width: 64"] [/TD]
[TD="class: xl7086, width: 64"] [/TD]
[/TR]
</tbody>[/TABLE]

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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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