excel - Transfer specific cells from each filtered area -


i have below code transfers visible data "prepsheet" "contract".

the code refers each visible section in prepsheet, resizes area in contract , transfers data.

i want refer specific columns within filtered area, can transfer column specific data individually. example, may want transfer 1st , 6th columns. please can assist

public rnga range sub test()     dim wb excel.workbook     set wb = activeworkbook      dim sourcews excel.worksheet     set sourcews = prepsheet      dim filtereddatarange excel.range      set filtereddatarange = sourcews.autofilter.range.offset(1, 0)       set filtereddatarange = filtereddatarange.resize(filtereddatarange.rows.countlarge - 1)      set filtereddatarange = filtereddatarange.specialcells(xlcelltypevisible)        dim destinationws excel.worksheet        dim destinationrow long       destinationrow = 1           dim area excel.range          each area in filtereddatarange.areas             set rnga = area             matchselectionarea         next area end sub  sub matchselectionarea() dim rng range, cel range dim nrows long dim ncols long set cel = contract.range("a1048576").end(xlup).offset(1, 0)       nrows = rnga.rows.count     ncols = rnga.columns.count        set rng = cel.resize(nrows, ncols)     rng.value = rnga.value  end sub 

you delving filtered rows , using number of filtered rows redefine filtered range. can copy straight out of filtered range , paste visible rows.

sub test()     dim wb excel.workbook, fdrng range, v long, vcols variant     dim sourcews worksheet, destinationws worksheet      set wb = activeworkbook     set sourcews = wb.worksheets("prepsheet")     vcols = array(1, 3, 5) 'columns a, c , e      sourcews         if .autofiltermode             .autofilter.range                 .resize(.rows.count - 1, .columns.count).offset(1, 0)                     v = lbound(vcols) ubound(vcols)                         .columns(vcols(v)).copy _                           destination:='you have provided no defined destination                     next v                 end             end         end if     end end sub  sub matchselectionarea()     dim rng range, cel range     dim nrows long, ncols long      worksheets("contract")         set cel = .range("a1048576").end(xlup).offset(1, 0)          nrows = rnga.rows.count         ncols = rnga.columns.count          'cannot determine         set rng = cel.resize(nrows, ncols)         rng = rnga.value     end  end sub 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -