Setting Chart Data points with an array?
I have a piece of code (vba) that goes through each row and gives it a graph (this works), however, due to the nature of the spreadsheet (Excel) I am working in, there may be as few as 2-5 data points and up to 20. Because of this, I can not simply hard code the columns of data and let the row number change as I previously had it. I have set up a selectcase statement that takes the two defining column factors, subtracts them and gives me how many columns I need that then inputs the correct amount of "A" & Row# & ",B" & Row# etc, into a string, however when I use the ActiveChart.SetSourceData Source:=Range(ColumnAmtStr) statement I get either an error of 448 "Named argument not found" or 1004 "Method 'Range of object '_Global' failed".
Any words of advice?
Re: Setting Chart Data points with an array?
Can you go in the VBE, do Tools > References, and look to see if one of the checked references (which are all at the top of the list) starts with MISSING. Try to just uncheck it and see if the error disappeared. If that doesnt work then create a new module and put the code in there instead of the worksheet.
Re: Setting Chart Data points with an array?
I found out that the problems were:
A.) I was using a String rather than a Range
B.) I did not include the sheet it was meant to get said data points from.
C.) I used "ActiveChart.SetSourceData Source:=Range(ColumnAmtStr)" when the correct format for a Range object was
"ActiveChart.SetSourceData Source:=ColumnAmtStr"
This one is as good as solved! Thanks for the help though.
:thumbup1: