views:

133

answers:

1

I was using this routine, triggered by the Worksheet_Change event, to display a selected chart and move all other charts to a holding position off screen.

Sub shuffleCharts(chartName As String)
    Dim analysisChart As ChartObject

    For Each analysisChart In ActiveSheet.ChartObjects
        With analysisChart
            .Left = 1575
        End With
    Next analysisChart

    With ActiveSheet.ChartObjects(chartName)
        .Left = 15
    End With
End Sub

It was working up until about 20 minutes ago but now refuses to reposition the charts. It doesn't throw any errors and the objects and variables all seem to be correct when checked in the Locals window.

The only thing I've been doing that may have in some way affected the charts is experimenting with ways to highlight the chart series data sources in another module. This was at a very early stage and was really only exploring the various methods and properties as I don't manipulate charts very often.

I've restarted Excel and checked a version from yesterday that was working when saved, but the result is the same. I've not rebooted yet as there is a bug db running on my machine which I'd prefer to wait until lunchtime to bring down. Edit: Got fed up and rebooted anyway - problem still exists.

Any idea what might have caused this, and how I might get it working again?

Edit: This gets weirder. By invoking the procedure manually like this:

Call shuffleCharts("Chart 1")

the procedure still works as expected. However, if I declare a string and pass that as the name of the chart...

Dim myChart as String
myChart = "Chart 1"
Call shuffleCharts(myChart)

...then it doesn't work. WTF?

Edit 2: I've confirmed that the code still performs as expected on other machines, so it just looks like my machine has been affected in some bizarre way by some "thing" I've done. I'm still curious to know what that "thing" might be though.

A: 

Well, I've sorted this, but am not really sure how. I was mucking about with connection objects and it seemed to fix itself.

Excel 1 - 0 Lunatik

Lunatik