csv - Excel 2010 Reference table data from one sheet to other -


i prepared data sheet contains primary database

             b          c 1   id         col2       col3 2   800         90        120 3   799         50        110 4   798         80        785 5   797         60        642 6   796         60        212 7   795         26        163 8   794         66        171 9   793         36        673 10  792         16        223 11  791         31        133 12  790         83        253 13  789         33        256 14  788         31        623 

i want create 3 more sheets named takeall, takeevery2nd, takeevery4th

what trying do:

take all - take data data sheet , display original:

             b          c 1   id         col2       col3 2   800         90        120 3   799         50        110 4   798         80        785 5   797         60        642 6   796         60        212 7   795         26        163 8   794         66        171 9   793         36        673 10  792         16        223 11  791         31        133 12  790         83        253 13  789         33        256 14  788         31        623 

take every 2nd - take every second row, meaning take 1st id 800 , skip every 2nd (will show id's 800, 798, 796, 794, 792, 790)
, this:

             b          c 1   id         col2       col3 2   800         90        120 4   798         80        785 6   796         60        212 8   794         66        171 10  792         16        223 12  790         83        253 14  788         31        623 

take every 4th- take first row , take every 4th meaning:

             b          c 1   id         col2       col3 2   800         90        120 6   796         60        212 10  792         16        223 14  788         31        623 

note:

`data` modified , new rows planned added 

i having difficulties understand how approach it

as mentioned in comment, using mod function in 'helper' column sequence staggers seems choice.

sub break_many()     dim rw long, v long, vmods variant, vwss variant      vmods = array(1, 2, 4)     vwss = array("takeall", "takeevery2nd", "takeevery4th")      sheets("sheet4")   '<-set worksheet reference!         if .autofiltermode .autofiltermode = false         v = lbound(vmods) ubound(vmods)             .cells(1, 1).currentregion                 .offset(1, .columns.count).resize(.rows.count - 1, 1)                     .formula = "=mod(row(1:1)-1, " & vmods(v) & ")"                 end             end             .cells(1, 1).currentregion                 .autofilter field:=.columns.count, criteria1:=0                 .resize(.rows.count, .columns.count - 1)                     .copy destination:=sheets(vwss(v)).cells(1, 1)                 end                 .autofilter field:=.columns.count                 .offset(1, .columns.count - 1).resize(.rows.count - 1, 1)                     .clear                 end             end         next v         if .autofiltermode .autofiltermode = false     end end sub 

that depend upon 3 target worksheets existing , not clear target before pasting data.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -