Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Excel VBA values

Posted on 2004-11-04
Medium Priority
Last Modified: 2008-01-09
OK I need the .gif output from this script to be NOT the chart Title but a cell value...
What the heck is the way to do this...


This is a snippet for the gif output
    ThisImage = "C:\test05\" & ActiveChart.ChartTitle.Text & ".gif"
         chtChart.Export Filename:=ThisImage, FilterName:="GIF"

I need the values from

=Sheet1!R & i & C2

as it cycles through the for i

This is the whole script.

Sub AddChart()
Dim chtChart As Chart
For i = 2 To 255
Set chtChart = Charts.Add
With chtChart

    ActiveChart.ChartType = xlLineMarkers
        ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("C" & i & ":K" & i), PlotBy:= _

    ActiveChart.SeriesCollection(1).Name = "=""African American"""
 ActiveChart.SeriesCollection(1).HasDataLabels = True
    ActiveChart.SeriesCollection(2).Values = "=Sheet1!R" & i & "C12:R" & i & "C20"
    ActiveChart.SeriesCollection(2).Name = "=""Hispanic"""
 ActiveChart.SeriesCollection(2).HasDataLabels = True
      ActiveChart.SeriesCollection(3).Values = "=Sheet1!R" & i & "C21:R" & i & "C29"
    ActiveChart.SeriesCollection(3).Name = "=""White"""
       ActiveChart.SeriesCollection(3).HasDataLabels = True

      ActiveChart.SeriesCollection(4).Values = "=Sheet1!R" & i & "C30:R" & i & "C38"
    ActiveChart.SeriesCollection(4).Name = "=""Total"""
     ActiveChart.SeriesCollection(4).HasDataLabels = True
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R259C3:R259C11"
    'ActiveChart.Location Where:=xlLocationAsNewSheet

    With ActiveChart
        .HasTitle = True
        .ChartTitle.Text = "=Sheet1!R" & i & "C2"
        .Axes(xlCategory, xlPrimary).HasTitle = False
        .Axes(xlValue, xlPrimary).HasTitle = False
            .HasAxis(xlCategory, xlPrimary) = True
        .HasAxis(xlValue, xlPrimary) = True
    End With
    ActiveChart.HasDataTable = True
    ActiveChart.DataTable.ShowLegendKey = True
       ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
    End With
    ThisImage = "C:\test05\" & ActiveChart.ChartTitle.Text & ".gif"
         chtChart.Export Filename:=ThisImage, FilterName:="GIF"
Next i

End Sub
Question by:hbojorquezgeek
1 Comment
LVL 50

Accepted Solution

Dave Brett earned 2000 total points
ID: 12500189
You can make a text string using ranges such as below, there is a test that A1 contains a value



    If Range("a1") <> "" Then
        ThisImage = "C:\test05\" & Range("a1") & ".gif"
        ThisImage = "C:\test05\Blank.gif"
    End If
    chtChartC.Export Filename:=ThisImage, FilterName:="GIF"

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Six Sigma Control Plans

581 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