Put every 2 columns into a new worksheet in excel -


is there vba scrip can take every 2 columns , turn new worksheet in same excel file? have 384 sets of columns needing turned new sheets. have 618 data points each column, if useful setting vba parameters.

i have tried searching answer online, , have found problem solved splitting every 900 rows new worksheet in same excel file, nothing columns. please see code below. have recorded macro , not written script, novice vba. tried replacing word row column in below script , changing 900 2, did not work either.

sub test() dim lastrow long, myrow long, mysheet worksheet lastrow = thisworkbook.sheets("sheet1").cells(rows.count, 1).end(xlup).row myrow = 2 lastrow step 900 set mysheet = worksheets.add sheets("sheet1").rows(myrow & ":" & myrow + 899).entirerow.copy       mysheet.range("a1") next myrow end sub 

i appreciate time , matter using code dozens of times.

thank you!

your code far being correct, @ least made effort of posting code. below tested, , works. prefer using ron de bruin's function finding last cells. can find on site, pasted herebelow well.

sub test()    dim lastrow integer, lastcolumn integer, v variant   dim ws worksheet, nws worksheet, integer    set ws = thisworkbook.sheets("sheet1")   lastrow = rdb_last(1, ws.cells)   lastcolumn = rdb_last(2, ws.cells)    = 1 lastcolumn step 2      v = ws.range(ws.cells(1, i), ws.cells(lastrow, + 1))     set nws = worksheets.add     nws.cells(1, 1).resize(ubound(v, 1) + i, ubound(v, 2)).value = v     set nws = nothing    next  end sub   function rdb_last(choice integer, rng range) ' ron de bruin, 5 may 2008 'returns address of last cell. row or column ' choice of 1 = last row. ' choice of 2 = last column. ' choice of 3 = last cell.    dim lrw long    dim lcol integer     select case choice     case 1:       on error resume next       rdb_last = rng.find(what:="*", _                           after:=rng.cells(1), _                           lookat:=xlpart, _                           lookin:=xlformulas, _                           searchorder:=xlbyrows, _                           searchdirection:=xlprevious, _                           matchcase:=false).row       on error goto 0     case 2:       on error resume next       rdb_last = rng.find(what:="*", _                           after:=rng.cells(1), _                           lookat:=xlpart, _                           lookin:=xlformulas, _                           searchorder:=xlbycolumns, _                           searchdirection:=xlprevious, _                           matchcase:=false).column       on error goto 0     case 3:       on error resume next       lrw = rng.find(what:="*", _                     after:=rng.cells(1), _                     lookat:=xlpart, _                     lookin:=xlformulas, _                     searchorder:=xlbyrows, _                     searchdirection:=xlprevious, _                     matchcase:=false).row       on error goto 0        on error resume next       lcol = rng.find(what:="*", _                      after:=rng.cells(1), _                      lookat:=xlpart, _                      lookin:=xlformulas, _                      searchorder:=xlbycolumns, _                      searchdirection:=xlprevious, _                      matchcase:=false).column       on error goto 0        on error resume next       rdb_last = rng.parent.cells(lrw, lcol).address(false, false)       if err.number > 0          rdb_last = rng.cells(1).address(false, false)          err.clear       end if       on error goto 0     end select end function 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -