How do I expedite this Excel VBA macro? -
i know little bit of vba looking smarter ways (the ways people work!!).
here trying do. have deal data has
year | month | day | hour | minute | data1 | data2.... | datan
each in separate column , has thousands of rows. number of "data" columns defined user during run time (at least 1 , max 100). data may have time step eg every minute, 5 mins, 10 mins, each hour, daily , on. user specifies output data interval greater input data interval.
so, macro supposed write data in interval specified user. data in each column in between output time step has added togther. see following 2 tables:
input:
yr mth day hr min data_1 data_2 2010 2 7 8 0 1.01 2.01 2010 2 7 8 5 1.02 2.02 2010 2 7 8 10 1.03 2.03 2010 2 7 8 15 1.04 2.04 2010 2 7 8 20 1.05 2.05 2010 2 7 8 25 1.06 2.06 2010 2 7 8 30 1.07 2.07 2010 2 7 8 35 1.08 2.08 2010 2 7 8 40 1.09 2.09 2010 2 7 8 45 1.10 2.10 2010 2 7 8 50 1.11 2.11 2010 2 7 8 55 1.12 2.12 2010 2 7 9 0 1.13 2.13 2010 2 7 9 5 1.14 2.14
output:
yr mth day hr min data_1 data_2 2010 2 7 8 0 1.01 2.01 2010 2 7 8 15 3.09 6.09 2010 2 7 8 30 3.18 6.18 2010 2 7 8 45 3.27 6.27 2010 2 7 9 0 3.36 6.36
so, input data every 5 minute , output data has every 15 minute. each row of data between successive 15 minutes interval have added together.
i have thing working use 2 loops traversing horizontally , vertically , writing values spreadsheet @ each step. slow.
any expedite process appreciated.
thanks in advance
-mp
** code have been using write processed data text file:
open fname output access write #fnum rowndx = startrow endrow done = int((rowndx / endrow) * 100) application.statusbar = "exporting *.gag file... (" & done & " % done )" wholeline = "" colndx = startcol endcol if sheets("output").cells(rowndx, colndx).text = "" cellvalue = "" else cellvalue = sheets("output").cells(rowndx, colndx).text end if wholeline = wholeline & cellvalue & sep next colndx wholeline = left(wholeline, len(wholeline) - len(sep)) print #fnum, wholeline next rowndx close #fnum
is there way write range text file @ once. trying avoid looping.
thanks help
mpd
have tried setting
application.screenupdating = false application.calculation = xlcalculationmanual
before loops?
remember set
application.screenupdating = true application.calculation = xlcalculationautomatic
after loops have completed.
you might save of data array in loops , writing entire array range output spreadsheet, instead of writing values cell-by-cell, seems doing now.
Comments
Post a Comment