Solved

EXCEL spreadsheets... Graphs and Automating! VB?

Posted on 2004-10-21
361 Views
Last Modified: 2010-04-17
I have over three hundred graphs that I need to create from an EXCEL spreadsheet.
They're pretty complex with four series in each graph.
How can I automate this task?
0
Question by:hbojorquezgeek
    4 Comments
     

    Expert Comment

    by:SuperCableMan
    I'm not familiar with any of the methods, but i know its possible to do this with EXCEL 2003 and COM.  I know this won't win me any points, but I hope it gets you in the right direction.
    0
     
    LVL 11

    Expert Comment

    by:sachiek
    First step is to enable VBA and then do one time.

    It means when you do it, automatically VBA code will be generated.

    So just that VBA code.
    Modifiy it accordingly that it becomes generic.

    Then you can just put a loop where you pull the data from one point, insert into those automation code, then save those excel sheets.

    Funda stuff.

    Are you listen...? Reply me. So then we can discuss further

    Sachi
    0
     
    LVL 24

    Accepted Solution

    by:
    Hi SuperCableMan,
    creating the chart shouldn't be a problem. setting the sourcedata range of each chart will be the tricky part. How is the data organised in your sheet? are they is some kind of order?
    The following code assumes that your sheet1 has data in A1:D50. first chart's source will be A1:D5 the next chart A6:D10 and so on...

    Sub AddChart()
    Dim chtChart As Chart
    For i = 1 To 50 Step 5
    Set chtChart = Charts.Add
    With chtChart
    .Name = "chart" & i
    .ChartType = xlColumnClustered
    .SetSourceData Source:=Sheets("Sheet1").Range("A" & i & ":D" & i + 4), PlotBy:=xlRows
    .HasTitle = True
    .ChartTitle.Text = "chart" & 1
    .Axes(xlCategory, xlPrimary).HasTitle = True
    .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
    .Axes(xlValue, xlPrimary).HasTitle = True
    .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Sales"
    End With
    Next i
    End Sub

    btw to use the code open your workbook hit alt+f11, this opens the vbe window. here select module form the insert menu and paste the code below. close the vbe window, back in xl, hit alt+f8 select AddChart and click on run. 50 charts will be created using the data A1:D50

    Rajesh
    0
     
    LVL 24

    Expert Comment

    by:R_Rajesh
    R_Rajesh,
    >>50 charts will be created using the data A1:D50
    that should have been
    10 charts will be created using the data A1:D50
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    character entities and entity references in XML 17 62
    tripleUp challenge 7 47
    sumDigits  challenge 7 28
    changeXy challenge 13 27
    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    3 Experts available now in Live!

    Get 1:1 Help Now