VBScript Split Large excel file into smaller File after every 50,000 rows -


i have been asked split large excel file 1,000,000+ rows smaller excel files after number of rows user decides via inputbox, before happen have ask user if replace specfic columns "#####" using inputbox once info columns has been stored variable usercensor, take number entered row split, store usersplit , split file @ interval specified in usersplit.

this have far , experienceing major brain fart , don't know go here:

set app = createobject("excel.application")  set fso = createobject("scripting.filesystemobject")  each f in fso.getfolder("y:\blahblahblah").files   if lcase(fso.getextensionname(f)) = "xls"     set wb = app.workbooks.open(f.path)  set sh = wb.sheets("sheet 1") row = 1  lastrow = sh.usedrange.rows.count  lastcolumn = sh.usedrange.columns.count  strrow = lastrow  usersplit = inputbox("enter when want split between 1 - " + strrow)  strcolumn = lastcolumn  usercensor = inputbox("enter columns censor (format example: 'a:a' deletes column a) between 1 - " + strcolumn)  if usercensor.isnumeric columns(usercensor).select     selection.replace("######")  r = row lastrow if lastcolumn > 1     else 

it isn't go off appreciated!

thanks again!

you try dividing content smaller parts:

firstrow  = ws.usedrange.rows(1).row lastrow   = ws.usedrange.rows(ws.usedrange.rows.count).row usersplit = clng(inputbox("enter when want split between 1 - " _             & lastrow-firstrow+1))  n = 0 srcrow = firstrow lastrow   dstrow = (srcrow - firstrow) mod usersplit + 1   if dstrow = 1     n = (srcrow - firstrow) \ usersplit     if n > 0       wb2.saveas "c:\path\to\out" & n & ".xls"       wb2.close     end if     set wb2 = xl.workbooks.add   end if   ws1.cells(srcrow, 1).entirerow.copy   wb2.sheets(1).cells(dstrow, 1).pastespecial xlall next wb2.saveas "c:\path\to\out" & (lastrow - firstrow) \ usersplit & ".xls" wb2.close 

as deleting columns, wouldn't easier delete columns instead of replacing content else?


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -