Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Graph Names in VB 1

Status
Not open for further replies.

GovNewbi

Technical User
Jul 14, 2010
83
CA
I have recorded a macro to generate a graph from a table that is filled with information from a userform. When I record the macro it gives the graph a name like "Graph 1" but then when I clear the info in the table and run the macro again it does not recognize the name "Graph 1" anymore. It also does not want to let me rename it using activechart.name = "name" HELP.
 

What is the value (string) in Sheet1 Column A for the SerNum value?


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Like what is in cell A156 and A155??? I'm not sure what you are asking, I don't know program talk very well.

Cell A155 = 001
Cell A156 = 004

All the series names will be three digit numbers
 



I can't imagine why that would cause an error.

Another tool: faq707-4594

Sometimes using the Watch Window in debug, you can discover important things about your ovjects and variables.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Ok I think I am on track to figuring it out. When I opened the select data source I noticed the pieces I want to rename arn't under series like they were when I recorded it but they are now under the "Horizontal (Category) axis labels" which actually kinda works better. Those are what I need to re-name though. Which I think also explains why I got the error the second time through, there was only the one series.
 
I'm assuming I'm going to use ActiveChart.Axes(xlCategory) but I don't know how to make this work for i number of categories.
 



You can have one Primary Category axis and one Secondary Category axis.
Code:
With Cht.Axes(xlCategory, xlPrimary)

End with
With Cht.Axes(xlCategory, xlSecondary)

End with
Check the Axes object in VBA Help.

I think you are referring to multiple SERIES.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Ya I just had a look in the help thing. But I am confused because as I understand it you can only name a maximum of two categories? I have like 6 right now and there would potentialy be more or less depending on user input.

Basically it is a bar graph, I have 6 bars, I want each bar to be labeled on the horizontal axis using the values listed starting at StProj. (6 being the i value that can vary)
 


6 bars -- 6 series, all labled on the category axis.

Do you mean columns or bars? They are oriented differently: bars horizontal; columns vertical.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


6 columns -- 6 series, right?

You can reference the LABLES you want on the cat axis in the chart's SourceData tab.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I'm not sure what you mean by 6 series. I have a bar graph. It has 6 COLUMNS (vertical bars)all of these columns represent the same cost so they are all the same colour. I want their horizontal axis labels to be set.

I know you can change it in the sourcedata tab but when I change it it will only change the 6 I have and if I record it that is all well and good but again it only works for the 6 I have (I need this to be able to adjust to the number of values in the table).
 



Please post a representative sample of data that shows the data that you want to plot, and explain how you want the chart to display the results.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
ya I have been trying to figure that out to. I was going to post a table and an example graph. But I am almost never on forums and I have no clue how to do that either :(
 


Just post the DATA for now in tabular form.

Several of us cannot access data files posted, due to tight security where we work.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Table Co-Generation Plants
002 2000
003 2365
004 2568
005 2456
006 3165
008 3459
014 2547
023 1985
056 1459


I want in this case 9 columns (named 002, 003, ect), the y axis is 1459-3459, and the label on the side says "co-generation plants" beside the little blue square showing the colour of the columns.
 


Select your data table.

Insert a cluster column.

Category axis is you 9 3-digit values

Columns vary from ~1500 to ~3500

Easy peasy!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I don't understand that. And also all those number will vary depending on the user input so I don't see how I can just set them and call it good.

I figured out why the one portion of code was failing when I got to naming the second series though. It is because depending on the graph previously made there are not always the same number of series there as I want to name.

I have no idea how to fix this and I am having a nightmare of a day already so I don't know if this explinaiton will even be any good but I will give it a try...

When you open "select data source" there are two columns, "Legend entry (series)" and "horizontal (category) axis label". I need to know how to write vb code that will set the number of series to equal the number of values in a column of my table.
 



You really did not post waht I asked.

I need to see an example of data that reflects MORE than one chart-display's worth of data and the logic behind how any display subset is defined.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I am so in over my head. I don't get it. I think you are trying to say that you want to see multiple variations of the table data that I will be graphing???

If so do you want to see variations of the same type of graph or different ones? cuz all the numbers will vary in every type of graph and then the entire format and the numbers will vary in the four different types of graphs.
 


I am trying to understand exactly what you need to plot in one chart. Is there any variability in the RANGE(s) or is it a fixed range?

If it's variable, then what's the logic for selecting each variation?

If it's fixed, there should be no ambiguity.

You posted ONE column of data with 9 data points. That would be displayed as ONE series with then x-category axis having the 3-digit values and the y-value axis displaying the columns, each column length relative to it's numeric value.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top