Jon,
Thanks for the tip.
I ended up using the msgbox to work out what graph was being called.
Then I just changed the order they were in the drop down box and everything
is now fine.
"Jon Peltier" wrote in message
...
Are you declaring variables? You have two lines in conflict:
currentchart = ""
and
Set currentchart = Sheets("Charts").ChartObjects(ChartNo).Chart
You should have a line that says
Dim currentchart As Chart
That lecture on best programming practices aside (as if I'm the expert),
you need to refer to the chart names, not their numbers:
testChartName = "My Chart"
Set currentchart = Sheets("Charts").ChartObjects(testChartName ).Chart
- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______
Geeves wrote:
I double checked all Chart Names, even checked what the macor would be
called for each.
I have gone through every thing I can think of and I have tracked down
the
porblem to the set currentchart when I changed the UpdateChart Macro
I included a msgbox to see what it was actually referencing. When I ran
it
I found that for Chart 2 it was selecting Chart 6
So despite ChartNo =2 it was giving me Chart 6 in the MSgBox anf then
Chart
6 would be appearing in the form.
Can anyone tell me why it would be giving me the error as this is
totally
beyond me.
Private Sub UpdateChart()
currentchart = ""
testChartName = ""
Set currentchart = Sheets("Charts").ChartObjects(ChartNo).Chart
' CName = currentchart
Dim testChartName As String
testChartName = Sheets("Charts").ChartObjects(ChartNo).Name
MsgBox testChartName
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