Jump to content
Sign in to follow this  

Auto generate graphs and trend lines in Excel

Recommended Posts


I have a spreadsheet with customer names, months of a year, and usage data.

I want to create line graphs with the data and also use excels nifty trend lines to automate creating graphs for about 80 customers.

I do not want to make all of these myself.

Ideally this will be a program that I will run and it will reference the spreadsheet so it is always updated.

It will allow me to select a single customer and show me the graph with trend data for that particular customer.

Then I am also needing to be able to select ALL customers and show me a total usage trend.

I don't need to compare customer vs customer or anything, just look at 1 customer or ALL customers.

Can this be done in Autoit? Where would I start on using Excels graphing?

Share this post

Link to post
Share on other sites

This code is AutoIt version of this VB source.

#include <Excel.au3>

Global Const $xlRows = 1

Local $avArray[5][4] = [["", "Region 1", "Region 2", "Region 3"], ["jan", 10, 80, 15], ["Feb", 20, 70, 25], ["Mar", 30, 60, 35], ["Apr", 40, 50, 45]]
Local $oExcel

$oExcel = _ExcelBookNew()
_ExcelWriteSheetFromArray($oExcel, $avArray, 3, 3, 0, 0)


$oRange = $oExcel.Selection.Address
$sSheetName = $oExcel.ActiveSheet.Name

$oExcel.ActiveSheet.ChartObjects.Add(125.25, 60, 301.5, 155.25).Select
$oExcel.Application.CutCopyMode = False

$oExcel.ActiveChart.ChartWizard( _
    $oExcel.Sheets($sSheetName).Range($oRange), _
    $xlLine, 4, $xlRows, 1, 1, 1, "", "", "", "")

Basically, you need to use an object browser and read the MSDN site documentation about a specific object, method, property etc..


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