Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 4
Default X-axis to cross Y-axis at avrg Y-value

Have been trying for ages to get the X-axis to cross the Y-axis at exactly
the avrg Y-value - to see results above and below average. But I can't find a
way to do it. Anyone?
(Tried recording a macro that takes the avrg value and pastes it into the
field in the "Value (X) axis crosses at" field, but it pastes the formula
rather than the number, and Excel can't handle a formula in that field...)

Thanks for any help
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default X-axis to cross Y-axis at avrg Y-value

The code is as simple as this:

With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With

dAverage is a variable that assumes the average value. If the average is
calculated in a cell, then before the code above, set dAverage's value like:

dAverage = ActiveSheet.Range("B2").Value

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Have been trying for ages to get the X-axis to cross the Y-axis at exactly
the avrg Y-value - to see results above and below average. But I can't
find a
way to do it. Anyone?
(Tried recording a macro that takes the avrg value and pastes it into the
field in the "Value (X) axis crosses at" field, but it pastes the formula
rather than the number, and Excel can't handle a formula in that field...)

Thanks for any help



  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 4
Default X-axis to cross Y-axis at avrg Y-value

Thanks a lot for the answer, but I still can't make it work. I inserted the
code, but it returns an error. I have now recorded a macro where I insert
manually the value "150". That works. Only 150 is not the average. Replacing
that value with "dAverage" doesn't work.

What am I doing wrong?

With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 150
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

"Jon Peltier" wrote:

The code is as simple as this:

With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With

dAverage is a variable that assumes the average value. If the average is
calculated in a cell, then before the code above, set dAverage's value like:

dAverage = ActiveSheet.Range("B2").Value

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Have been trying for ages to get the X-axis to cross the Y-axis at exactly
the avrg Y-value - to see results above and below average. But I can't
find a
way to do it. Anyone?
(Tried recording a macro that takes the avrg value and pastes it into the
field in the "Value (X) axis crosses at" field, but it pastes the formula
rather than the number, and Excel can't handle a formula in that field...)

Thanks for any help




  #4   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default X-axis to cross Y-axis at avrg Y-value

You need a line of code that assigns a value to dAverage

with ActiveChart
dAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With
end with

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Thanks a lot for the answer, but I still can't make it work. I inserted
the
code, but it returns an error. I have now recorded a macro where I insert
manually the value "150". That works. Only 150 is not the average.
Replacing
that value with "dAverage" doesn't work.

What am I doing wrong?

With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 150
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

"Jon Peltier" wrote:

The code is as simple as this:

With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With

dAverage is a variable that assumes the average value. If the average is
calculated in a cell, then before the code above, set dAverage's value
like:

dAverage = ActiveSheet.Range("B2").Value

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Have been trying for ages to get the X-axis to cross the Y-axis at
exactly
the avrg Y-value - to see results above and below average. But I can't
find a
way to do it. Anyone?
(Tried recording a macro that takes the avrg value and pastes it into
the
field in the "Value (X) axis crosses at" field, but it pastes the
formula
rather than the number, and Excel can't handle a formula in that
field...)

Thanks for any help






  #5   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 4
Default X-axis to cross Y-axis at avrg Y-value

Sorry, but my code looks exactly like yours, and it still doesn't work. It
says "Object or With block variable not set".

With ActiveChart
DAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
..Crosses = xlCustom
..CrossesAt = DAverage
End With
End With
End Sub

/Nicolai

"Jon Peltier" wrote:

You need a line of code that assigns a value to dAverage

with ActiveChart
dAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With
end with

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Thanks a lot for the answer, but I still can't make it work. I inserted
the
code, but it returns an error. I have now recorded a macro where I insert
manually the value "150". That works. Only 150 is not the average.
Replacing
that value with "dAverage" doesn't work.

What am I doing wrong?

With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 150
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

"Jon Peltier" wrote:

The code is as simple as this:

With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With

dAverage is a variable that assumes the average value. If the average is
calculated in a cell, then before the code above, set dAverage's value
like:

dAverage = ActiveSheet.Range("B2").Value

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Have been trying for ages to get the X-axis to cross the Y-axis at
exactly
the avrg Y-value - to see results above and below average. But I can't
find a
way to do it. Anyone?
(Tried recording a macro that takes the avrg value and pastes it into
the
field in the "Value (X) axis crosses at" field, but it pastes the
formula
rather than the number, and Excel can't handle a formula in that
field...)

Thanks for any help








  #6   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default X-axis to cross Y-axis at avrg Y-value

Which line is highlighted? Have you activated a chart?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Sorry, but my code looks exactly like yours, and it still doesn't work. It
says "Object or With block variable not set".

With ActiveChart
DAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = DAverage
End With
End With
End Sub

/Nicolai

"Jon Peltier" wrote:

You need a line of code that assigns a value to dAverage

with ActiveChart
dAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With
end with

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Thanks a lot for the answer, but I still can't make it work. I inserted
the
code, but it returns an error. I have now recorded a macro where I
insert
manually the value "150". That works. Only 150 is not the average.
Replacing
that value with "dAverage" doesn't work.

What am I doing wrong?

With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 150
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

"Jon Peltier" wrote:

The code is as simple as this:

With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With

dAverage is a variable that assumes the average value. If the average
is
calculated in a cell, then before the code above, set dAverage's value
like:

dAverage = ActiveSheet.Range("B2").Value

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Have been trying for ages to get the X-axis to cross the Y-axis at
exactly
the avrg Y-value - to see results above and below average. But I
can't
find a
way to do it. Anyone?
(Tried recording a macro that takes the avrg value and pastes it
into
the
field in the "Value (X) axis crosses at" field, but it pastes the
formula
rather than the number, and Excel can't handle a formula in that
field...)

Thanks for any help








  #7   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 4
Default X-axis to cross Y-axis at avrg Y-value

No line is highlighted, actually. Yes, a chart is activated. I can manually
make the X-axis cross Y at the average Y-value, but the Macro doesn't do the
trick. Is it because I am not telling it which values to calculate the
average for? Does the code do that?

It looks like this (you can tell, I have tried 32 times...)

Sub Macro32()
'
' Macro32 Macro
' Macro recorded 05-09-2008 by Nicolai Kristiansen
'

'
With ActiveChart
DAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = DAverage
End With
End With
End Sub

/Nicolai

"Jon Peltier" wrote:

Which line is highlighted? Have you activated a chart?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Sorry, but my code looks exactly like yours, and it still doesn't work. It
says "Object or With block variable not set".

With ActiveChart
DAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = DAverage
End With
End With
End Sub

/Nicolai

"Jon Peltier" wrote:

You need a line of code that assigns a value to dAverage

with ActiveChart
dAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With
end with

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Thanks a lot for the answer, but I still can't make it work. I inserted
the
code, but it returns an error. I have now recorded a macro where I
insert
manually the value "150". That works. Only 150 is not the average.
Replacing
that value with "dAverage" doesn't work.

What am I doing wrong?

With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 150
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

"Jon Peltier" wrote:

The code is as simple as this:

With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With

dAverage is a variable that assumes the average value. If the average
is
calculated in a cell, then before the code above, set dAverage's value
like:

dAverage = ActiveSheet.Range("B2").Value

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Have been trying for ages to get the X-axis to cross the Y-axis at
exactly
the avrg Y-value - to see results above and below average. But I
can't
find a
way to do it. Anyone?
(Tried recording a macro that takes the avrg value and pastes it
into
the
field in the "Value (X) axis crosses at" field, but it pastes the
formula
rather than the number, and Excel can't handle a formula in that
field...)

Thanks for any help









  #8   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default X-axis to cross Y-axis at avrg Y-value

You get an error, but no line in the code is highlighted? It should tell us
which object or block variable is not set.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
No line is highlighted, actually. Yes, a chart is activated. I can
manually
make the X-axis cross Y at the average Y-value, but the Macro doesn't do
the
trick. Is it because I am not telling it which values to calculate the
average for? Does the code do that?

It looks like this (you can tell, I have tried 32 times...)

Sub Macro32()
'
' Macro32 Macro
' Macro recorded 05-09-2008 by Nicolai Kristiansen
'

'
With ActiveChart
DAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = DAverage
End With
End With
End Sub

/Nicolai

"Jon Peltier" wrote:

Which line is highlighted? Have you activated a chart?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Sorry, but my code looks exactly like yours, and it still doesn't work.
It
says "Object or With block variable not set".

With ActiveChart
DAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = DAverage
End With
End With
End Sub

/Nicolai

"Jon Peltier" wrote:

You need a line of code that assigns a value to dAverage

with ActiveChart
dAverage = WorksheetFunction.Average(.SeriesCollection(1).Val ues)
With .Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With
end with

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Thanks a lot for the answer, but I still can't make it work. I
inserted
the
code, but it returns an error. I have now recorded a macro where I
insert
manually the value "150". That works. Only 150 is not the average.
Replacing
that value with "dAverage" doesn't work.

What am I doing wrong?

With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 150
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

"Jon Peltier" wrote:

The code is as simple as this:

With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = dAverage
End With

dAverage is a variable that assumes the average value. If the
average
is
calculated in a cell, then before the code above, set dAverage's
value
like:

dAverage = ActiveSheet.Range("B2").Value

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nicolai" wrote in message
...
Have been trying for ages to get the X-axis to cross the Y-axis
at
exactly
the avrg Y-value - to see results above and below average. But I
can't
find a
way to do it. Anyone?
(Tried recording a macro that takes the avrg value and pastes it
into
the
field in the "Value (X) axis crosses at" field, but it pastes the
formula
rather than the number, and Excel can't handle a formula in that
field...)

Thanks for any help











Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stacked column charts that cross the X Axis valerie Charts and Charting in Excel 1 May 15th 08 02:11 AM
Can't get the x-axis to cross at value 0 for both y-axes Derek Charts and Charting in Excel 3 March 17th 08 09:20 PM
Need PivotChart x axis to cross Y axis at minimum Y axis value Aaron Charts and Charting in Excel 1 August 17th 07 08:51 AM
Y axis to cross at zero Paddy Charts and Charting in Excel 3 July 16th 06 08:28 AM
How do I make two y axis in bar graphs (i.e. cross hatching)?? ancientk Excel Discussion (Misc queries) 1 January 29th 06 08:53 PM


All times are GMT +1. The time now is 09:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"