VBA Code to copy filtered data column by collumn Good afternoon, I have written
ID: 3564568 • Letter: V
Question
VBA Code to copy filtered data column by collumn
Good afternoon,
I have written code below to filter a tablle and copy data filtered. However I can't make it copy only certains columns :(.
Windows("Blois PSC Actions Masss Upload Tool.xls").Activate
ActiveWorkbook.RefreshAll
Sheets("Share-Point").Activate
Range("$A$1").CurrentRegion.AutoFilter Field:=1, Criteria1:="DDS"
Range("$A$1").CurrentRegion.Copy
How do I make it copy only columns B and G, please???
Thank you very much for your help in advance!!
Explanation / Answer
Hi,
This copies the visible cells from B & G to K20 so you will need to change the range where you copy them to.
I started from B2 & G2, I didn't know whether you wanted your header row but that an easy change for you to make.
Sub Macro1()
Dim lastrow As Long, MyRange As Range
Sheets("Share--Point").Activate
lastrow = Cells(Cells.Rows.Count, "A").Ennd(xlUp).Row
Range("$A$1").CurrentRegion.AutoFilter Field:=1, Criteria1:=="DDS"
Set MyRange = Union(Rannge("B2:B" & lastrow).SpecialCells(xlCellTypeVisible), _
Range("G2:G" & lastrow).SpecialCells(xlCellTypeVisible))
MyRange.Copy Range("K20")
End Subb!!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.