PC Review


Reply
Thread Tools Rate Thread

autoscale stock chart

 
 
Tim
Guest
Posts: n/a
 
      21st Apr 2010
Hi All,
xl2003. A candle stick stock chart with some moving averages is located as a
new sheet. Trying to autoscale it using the next macro:
Dim intMax1 As Integer
Dim intMin1 As Integer
Dim intMax2 As Integer
Dim intMin2 As Integer
Dim rngMin As Range
Dim rngMax As Range

Set rngMin = Worksheets("Stock Data").Range("c2:d94")
Set rngMax = Worksheets("Stock Data").Range("c2:d94")

intMin1 = Application.WorksheetFunction.Min(rngMin)
intMin2 = Application.WorksheetFunction.RoundDown(intMin1, 0.1)

intMax1 = Application.WorksheetFunction.Max(rngMax)
intMax2 = Application.WorksheetFunction.RoundUp(intMax1,- 0.1)

ActiveChart.Axes(xlValue, xlSecondary).Select
With ActiveChart.Axes(xlValue, xlSecondary)
.MinimumScale = intMin2
.MaximumScale = intMax2
End With

The macro seems to work when the price of the stock is greater than $20. But
when the stock price is less than $5 the autoscaling macro doesn’t work
properly. Tried to add these lines to the above macro:
ActiveChart.Axes(xlValue, xlPrimary).Select
With ActiveChart.Axes(xlValue, xlPrimary)
.MinimumScale = intMin2
.MaximumScale = intMax2
End With

but received “Run-time error ‘1004’ “ message.
Also changed :
intMin2 = Application.WorksheetFunction.RoundDown(intMin1, +0.1)
intMax2 = Application.WorksheetFunction.RoundUp(intMax1, -0.1)
to
intMin2 = Application.WorksheetFunction.RoundDown(intMin1, +0.01)
intMax2 = Application.WorksheetFunction.RoundUp(intMax1, -0.01)
and there wasn’t any difference in the resulting chart.
I know how to autoscale the chart when it is located as object in the Data
sheet but this one (when the chart is located as a new sheet) drives me up to
the wall.
Any help is Highly appreciated.

 
Reply With Quote
 
 
 
 
Tim
Guest
Posts: n/a
 
      22nd Apr 2010
Problem solved. Ignore my previous post.
Tim


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can a stock chart be combined with an line chart? =?Utf-8?B?a2FyZW5qb3k1MTE=?= Microsoft Excel Charting 3 23rd Jul 2009 04:16 PM
Super 2-axis chart Autoscale Macro ;-) =?Utf-8?B?UGF0YWNob3Vw?= Microsoft Excel Programming 5 4th Jun 2007 10:41 PM
Autoscale a Line Chart to stack the curves =?Utf-8?B?UGF0YWNob3Vw?= Microsoft Excel Charting 5 20th Apr 2007 01:26 PM
Define Autoscale parameters in Chart =?Utf-8?B?cnVkZG9qbw==?= Microsoft Excel New Users 0 8th Oct 2006 06:46 AM
Autoscale horizontal axis on chart JzP Microsoft Powerpoint 4 6th Apr 2006 06:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:52 AM.