
VBA EXCEL97: How to get the range from a chart into a range object
Hi all,
I'm trying to optimize a process that makes a presentation in
powerpoint from data that is updated monthly. Data is inserted into
excel from a query updating some 120 pivotables and producing 120
charts.
Excel messes up the data a bit. Often the sourcedata of the chart
stay's correct, but row and colums are switched. I'm trying to build a
macros that corrects this situation. I'm getting stuck with getting
the rangwe from the current chart.
Any help
Cees
Sub CorrigeerGrafieken()
'Gemaakt door Cees Harlaar (Brunel ICT)
'16-9-2002
Dim mySheet As Object
'Dim myChart As Object
Dim myRange As Range
Dim myIndex As Object
Dim ChartItemCount As Integer
Dim iTeller As Integer
Dim strSheet As String
Dim strChart As String
Dim intVolgnummer As Integer
Set dlgSource = ThisWorkbook.DialogSheets("dlgSource")
For Each mySheet In ActiveWorkbook.Sheets
Sheets(mySheet.Name).Select
'iTeller = 0
If InStr(1, ActiveSheet.Name, "Query D") Then
ChartItemCount = ActiveSheet.ChartObjects.Count
'MsgBox ActiveSheet.Name & " " & ChartItemCount
For iTeller = 1 To ChartItemCount
ActiveSheet.ChartObjects.Item(iTeller).Select
Set myRange =
Range(dlgSource.EditBoxes("ChartSource").Text)
ctiveChart.SetSourceData Source:=Sheets("Query D for
Dubai").Range( _
myRange), PlotBy:=xlRows
Next
End If
Next
On Error Resume Next
Kill "c:\data\tempdata.txt"
End Sub