Don't quite know what you mean by "it just seems to go loopy." Does it
mean that you get the wrong chart? No chart? Loops forever? Crashes?
Something else?
If the first, it could be because you are referencing charts (or more
accurately, chartobjects) by their numeric index. Unfortunately, there
is nothing concrete about how those numbers relate to the charts on a
worksheet. For example, if you exchange the locations of two charts,
it doesn't change their numeric index.
You might be better off giving each chartobject a name and using that
for index purposes.
--
Regards,
Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
In article ,
says...
Can some kind sole please help me here.
I am display 13 charts one at a time into a userform via a drop down box
titled: ChartType
I have adapted the coding from John Walkenbach's site
http://j-walk.com/ss/excel/tips/tip66.htm
But the problem I get is that it displays the wrong chart. It works fine
for Chart 1 but after that it just seams to go loopy when I try and load in
another chart
Any suggestions would be greatly appreciated.
--------------------------------------------
Dim ChartNo As Integer
Private Sub GetChart_Click()
ChartNo = 0
CheckValue = Charts.ChartType.ListIndex + 1
ChartNo = CheckValue
UpdateChart
End Sub
Private Sub UpdateChart()
Set CurrentChart = Sheets("Charts").ChartObjects(ChartNo).Chart
CurrentChart.Parent.Width = 420
CurrentChart.Parent.Height = 190
' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export Filename:=Fname, FilterName:="GIF"
' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub