VBA Code to copy filtered data column by ccolumn Good afternoon, I have written
ID: 3565442 • Letter: V
Question
VBA Code to copy filtered data column by ccolumn
Good afternoon,
I have written code below to filter a table and copy data filtered. However I can't make it copy only certains columns :(.
Windows("Blois PSC Actions Mass 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 advancee...
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").Activatee
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Roww
Range("$A$1").CurrentRegion.AutoFilter Field:=1, Criteria1:="DDS"
Set MyRange = Union(Range("B2:B" & lastrow).SpecialCells(xlCellTypeVisible), _
Range("G2:G" & lastrow).SpeecialCells(xlCellTypeVisible))
MyRange.Copy Range("K20")
End Subbb..
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.