Basically, I am trying to automate one of the tasks of my job into a macro, which is taking some data and putting it into a 5 series clustered column chart to make a visually appealing way to present the info. The issue is that the range length changes week to week depending on # of parts dealt with. I'm just running into a slight error when adding the series values, as excel isn't accepting my string argument. Below is what I have.
Sub FilterRankAndCreateChart()
Dim i As Integer
Dim rnge As String
i = 0
Sheets("MC Spares Risk Calculations").Select
Range("A1").Select
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
i = i + 1
Loop
Let rnge = "$J$2:$J$" & i
Worksheets("MC Risk Chart").Activate
ActiveSheet.ChartObjects(1).Activate
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(1).Name = "=""Low Risk"""
ActiveChart.FullSeriesCollection(1).Values = "='Risk Charts'!rnge"
ActiveChart.FullSeriesCollection(1).XValues = "='Risk Charts'!$B$2:$B$149"
The value of rnge as displayed in the immediate window is correct. but, when i use rnge to define the values, I get a 1004 error (application or object-defined error). Any insight on how to fix this?