excel vba - Filter and copy the data to new worksheet -


i want filter data , paste new sheet including first row (title). have below code copies data, not title. copy title along filtered data using vba:

sub macro1()   'suppose want filter data in columna & column b of sheet1.   range("a1").entirerow.insert    'find lastrow   dim lastline long   lastline = columns(1).find("*", , , , xlbycolumns, xlprevious).row    'add filter   range("a:l").autofilter field:=2, criteria1:=9701    'copy filtered data.   range("a1:l" & lastline).specialcells(xlcelltypevisible).copy    'paste sheet2   ws_count = activeworkbook.worksheets.count   set ws = sheets.add(after:=sheets(sheets.count))   sheets(sheets.count).range("a1").pastespecial   call filter end sub 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -