D
Dale Fye
I've been working on this for a couple of days now, so bear with me. I've
got some data (linked from an Access query) that looks like:
Mission Day Sorties
A 1 9
A 2 7
A 3 5
B 1 10
B 2 11
B 3 19
C 1 5
C 2 16
C 3 12
The types of missions vary, as do the number of day (although for a
particular query, the number of day will be constant across each of the
missions). What I want to do is dynamically format the data series of a
stacked bar chart so that each of the Missions is a different data series,
the days are the X-Axis Values, and the Sorties reflect the height of the
bars in the stacked bar chart.
I'm relatively new to Excel VBA, but have been using Access for about 10
years. I'm just not familiar with the Excel object model. The first
problem I am having is actually selecting the chart so that I actually have
an "ActiveChart" object. Can anyone help me out with that step?
Once I have selected a chart, I want to clear out it's SeriesCollection;
figured out a way to do that one series at a time but would be interested in
knowing if that can be done in a single step.
Next, I assume I am going to have to do some looping to identify the start
and end point of each series (mission), but should probably start out by
clearing out the Series collections. Is there an easy way within Excel to
identify the row that contains the next value. For example, Mission type
"A" starts on Row 2, and mission type "B" starts on row 5. Is there a quick
way to identify Row 5 without looping through each row and testing the value
of the first cell in each row against some preset value? In most cases, my
dataset will contain around a thousand rows (5-10 mission types)
I assume that once I define the start and end positions of each series, I'll
be able to use code similiar to the following to build the series.
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C2:R4C2"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!R2C3:R4C3"
ActiveChart.SeriesCollection(1).Name = "=Sheet1!R2C1"
Any help would be greatly appreciated
got some data (linked from an Access query) that looks like:
Mission Day Sorties
A 1 9
A 2 7
A 3 5
B 1 10
B 2 11
B 3 19
C 1 5
C 2 16
C 3 12
The types of missions vary, as do the number of day (although for a
particular query, the number of day will be constant across each of the
missions). What I want to do is dynamically format the data series of a
stacked bar chart so that each of the Missions is a different data series,
the days are the X-Axis Values, and the Sorties reflect the height of the
bars in the stacked bar chart.
I'm relatively new to Excel VBA, but have been using Access for about 10
years. I'm just not familiar with the Excel object model. The first
problem I am having is actually selecting the chart so that I actually have
an "ActiveChart" object. Can anyone help me out with that step?
Once I have selected a chart, I want to clear out it's SeriesCollection;
figured out a way to do that one series at a time but would be interested in
knowing if that can be done in a single step.
Next, I assume I am going to have to do some looping to identify the start
and end point of each series (mission), but should probably start out by
clearing out the Series collections. Is there an easy way within Excel to
identify the row that contains the next value. For example, Mission type
"A" starts on Row 2, and mission type "B" starts on row 5. Is there a quick
way to identify Row 5 without looping through each row and testing the value
of the first cell in each row against some preset value? In most cases, my
dataset will contain around a thousand rows (5-10 mission types)
I assume that once I define the start and end positions of each series, I'll
be able to use code similiar to the following to build the series.
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C2:R4C2"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!R2C3:R4C3"
ActiveChart.SeriesCollection(1).Name = "=Sheet1!R2C1"
Any help would be greatly appreciated