Hi
I am trying to create a vbo to change the data range for the XValues of a chart object in excel. I have it doing everything I need except it doesn't recognise the range value when its passed into the object as a parameter. Here's what I have so far
Dim sw, dw As Object
Dim ss, ds As Object
Dim excel, sheet, source, workbook, range As Object
Try
sw = GetWorkbook(CInt(Handle), Source_Workbook)
ss = GetWorksheet(CInt(Handle), Source_Workbook, Source_Worksheet)
sw.Activate()
ss.Activate()
excel = ss.Application
sheet = excel.ActiveSheet
workbook = excel.ActiveWorkbook
sheet.ChartObjects(Chart_Name).Activate()
workbook.ActiveChart.FullSeriesCollection(1).XValues = workbook.Sheets(Source_Worksheet).Range(Source_Range)
Success = True
Message = Chart_Name & " successfully updated"
Catch e As Exception
Success = False
Message = e.Message
Finally
sw = Nothing
ss = Nothing
dw = Nothing
ds = Nothing
excel = Nothing
sheet = Nothing
source = Nothing
End Try
If I defined the value specifically it works fine e.g. workbook.ActiveChart.FullSeriesCollection(1).XValues = "=Sheet1!$A$2:$B$2"
But obviously I would want to pass the range value as a parameter to make it dynamic. I know I'm missing something obvious here but I just cant put my finger on it.
Any suggestions?
------------------------------
Michael ONeil
Technical lead developer
Europe/London
------------------------------