Excel VBA values

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:= _
        xlRows
       

    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection.NewSeries
    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
hbojorquezgeekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DaveCommented:
You can make a text string using ranges such as below, there is a test that A1 contains a value

Cheers

Dave


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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.