Charts - Controlling Data Range with code

Daveyk01

Registered User.
Local time
Today, 13:15
Joined
Jul 3, 2007
Messages
144
I have a nice chart that hasd done what I wanted it too.

Now I want to make the amount of X-AXIS data variable. Typically this would be 64 points. If you look at the datasheet, I can manually set the number of points by making sure the row selector is "raised".

Now that's say there is only 16 points of data to control. I can plot that those points but the chart is still 64 points wide with no data for points 17-64.

How can I, through code, prevent points 17-64 from plotting and thereby expand the graph horizontally larger and not display those null points?

I have tried a number of things including:
objDataSheet.Row(17).Delete
Graph_Data.Range("A1:A16:)
etc...

Nothing I have tried has worked. Is what I need to do possible?

Thanks much.
 
I found I could delete rows like this:
strCell = ""
For X = 1 To 100
strCell = "A" + Trim(Str(X))
objDataSheet.Rows(X).Delete
objDataSheet.Range(strCell) = ""
Next X

...and then add as many row of data as need (i.e, 8 row, 16 rows, 32 rows, 64 rows) and the chart would adjust. The X-Axis label for each row is now gone.

I would like to be able to re-program in that label. Addrerssing a cell is easy (i.e., "A1") the X-AXIS labels go in the column before "A" I am trying to figure out how to address that.

I am getting throught this with a lot of brute forse time waiting effort. I can find little info on the web on how to use Chart. It is a wonder I have done as much with the charts as I have, but have been quite happy with it up until I have needed to make one's quantity of data source variable.
 
Okay, this worked, but I have to type in all the X-AXIS lables manually and save the table in design mode:

strCell = ""
For X = 1 To 66
strCell = "A" + Trim(Str(X))
objDataSheet.Rows(X).include = False
objDataSheet.Range(strCell) = ""
Next X
 

Users who are viewing this thread

Back
Top Bottom