[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Alternative to integer?

keri

12/15/2006 1:15:00 PM

Hi,

I have this code which sets the max scale on a chart. If i type into to
the scale in the format axis box a number such as 0.013808 then my
chart scale updates. However if "p7" (as referred to in the code has a
value of 0.013808 my macro does strange things with my chart. (The
scale goes crazy and the x axis meets at the top of the chart etc).

The only obvious reason for this is that I am defining maxy as an
integer, which from my small knowledge I seem to remember has to be a
whole number. What is the alternative if I want to define it as a
number with up to 8 decimal places?

Dim maxy as integer
maxy = activesheet.range("p7")

ActiveSheet.ChartObjects("Chart 32").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = 0.0004
.MaximumScale = maxy
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic

Many thanks.

3 Answers

Martin Fishlock

12/15/2006 1:31:00 PM

0

Keri

The help pages are very useful they describe the all the properties and
usually give a type definition.

For example

MaximumScale Property

Returns or sets the maximum value on the axis. Read/write Double.

Remarks
Setting this property sets the MaximumScaleIsAuto property to False.

Example
This example sets the minimum and maximum values for the value axis in Chart1.

With Charts("Chart1").Axes(xlValue)
.MinimumScale = 10
.MaximumScale = 120
End With

So in your code you use maxy as integer and when you assign 0.013808 ([p7])
to it gets rounded to zero and so therefore you have but max and min = 0 .

Use a double and it should work.

BTW was my other suggestion ok.

Please rate them as it shows that they are closed.

Thanks.



--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"keri" wrote:

> Hi,
>
> I have this code which sets the max scale on a chart. If i type into to
> the scale in the format axis box a number such as 0.013808 then my
> chart scale updates. However if "p7" (as referred to in the code has a
> value of 0.013808 my macro does strange things with my chart. (The
> scale goes crazy and the x axis meets at the top of the chart etc).
>
> The only obvious reason for this is that I am defining maxy as an
> integer, which from my small knowledge I seem to remember has to be a
> whole number. What is the alternative if I want to define it as a
> number with up to 8 decimal places?
>
> Dim maxy as integer
> maxy = activesheet.range("p7")
>
> ActiveSheet.ChartObjects("Chart 32").Activate
> ActiveChart.Axes(xlValue).Select
> With ActiveChart.Axes(xlValue)
> .MinimumScale = 0.0004
> .MaximumScale = maxy
> .MinorUnitIsAuto = True
> .MajorUnitIsAuto = True
> .Crosses = xlAutomatic
>
> Many thanks.
>
>

Bob Phillips

12/15/2006 1:48:00 PM

0

Define it as Double.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"keri" <keri.dowson@diageo.com> wrote in message
news:1166188472.391251.151890@l12g2000cwl.googlegroups.com...
> Hi,
>
> I have this code which sets the max scale on a chart. If i type into to
> the scale in the format axis box a number such as 0.013808 then my
> chart scale updates. However if "p7" (as referred to in the code has a
> value of 0.013808 my macro does strange things with my chart. (The
> scale goes crazy and the x axis meets at the top of the chart etc).
>
> The only obvious reason for this is that I am defining maxy as an
> integer, which from my small knowledge I seem to remember has to be a
> whole number. What is the alternative if I want to define it as a
> number with up to 8 decimal places?
>
> Dim maxy as integer
> maxy = activesheet.range("p7")
>
> ActiveSheet.ChartObjects("Chart 32").Activate
> ActiveChart.Axes(xlValue).Select
> With ActiveChart.Axes(xlValue)
> .MinimumScale = 0.0004
> .MaximumScale = maxy
> .MinorUnitIsAuto = True
> .MajorUnitIsAuto = True
> .Crosses = xlAutomatic
>
> Many thanks.
>


keri

12/15/2006 2:13:00 PM

0

Bob,

All posts have been excellent and very helpful, my thanks to everyone
who has given their time to getting me this far! I have learnt so much
and eventually will get my head around this!

I will go back and rate all posts now.

Many thanks to everyone for all of their help again.