Sign in to follow this  
Followers 0
Zolteg

Excel fill series automation

3 posts in this topic

G'day folks. Long time listener, first time caller...

I'm working on a script to automatically process a .csv file into excel. I need to extrapolate a series of dates & times from a start value and interval period given in the .csv, i.e. if start time = 2011/01/01 00:00, the interval is 60 seconds and the duration is a month, fill out a column from 2011/01/01 00:00 to 2011/01/31 23:59 with each value cell by cell, minute by minute.

I *could* write a simple loop that begins with the start time, writes the value into cell 1, increments the value by 60 seconds & writes to cell 2 ad infinitum, but that's rather slow and less than pretty. I really want to use excel's Fill Series function.

However, being a very nub scripter, I can't work out how to invoke this.

The VBA equivalent line is:

Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, Step:=0.0006944444, Stop:=40544, Trend:=False

I've searched the forums and have tried a bunch of code syntaxes for converting this but can't find an exact match. I'm hoping someone out there might be able to either scribe me the equivalent code (and advise any relevant #includes - I'm only including the standard 'excel.au3' include) or point me to a resource that'll explain how in very simple english.

Cheers,

Z

Share this post


Link to post
Share on other sites



Not sure exactly what you want to do, but this is a working example, hopefully it's somewhere in the ballpark...?

#include <Excel.au3>

$oExcel = _ExcelBookNew()

_ExcelWriteCell($oExcel, "2011/01/01 00:00:00", 1, 1)
_ExcelWriteCell($oExcel, "2011/01/01 00:01:00", 2, 1)

$iNoFills = 44640

$oExcel.ActiveSheet.Range("A1:A2").Select
With $oExcel
    .Selection.AutoFill(.Range("A1:A" & $iNoFills),0)
EndWith

Exit

Share this post


Link to post
Share on other sites

Not sure exactly what you want to do, but this is a working example, hopefully it's somewhere in the ballpark...?

Effectively, I was trying to emulate this series of sends:

$oExcel.cells(22,1).Select
send("!e")
send("!i")
send("!s")
send("!c")
send("!s.00069444444")
send ("!o40544")
send("{ENTER}")
sleep(500)

However, with your guidance I've just eliminated the seconds entry from my spreadsheet, and came out with:

_excelwritecell($oExcel,$DateTime,22,1)
$DateTime= $yearval & "/" & $Monthval & "/" & $dayval & " " & $hourval & ":" & $minval+1
_excelwritecell($oExcel,$DateTime,23,1)
$DateTime= $yearval & "/" & $Monthval & "/" & $dayval & " " & $hourval & ":" & $minval


$oExcel.ActiveSheet.Range("A22:A23").Select
With $oExcel
    .Selection.AutoFill(.Range("A22:A" & $totalrecords+22),0)
EndWith

Many thanks for the prompt response.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0