Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Creating Second Chart via Sub Procedure Error

Hi,

I have a set of data (date, price) for a number (the actual number
depends on the user input from a previous form) of bonds, and I plot
this, via VBA on a single chart, with multiple series.

I then normalise this data, and then plot the normalised data on
another chart. All in the same workbook. I therefore created a
sub-procedure to create the graphs. Part code is below:

'Previous code reads in data from Db and creates 2 worksheets
'One with standard data, the other with Normalised.
'Then the Code calls the sub to create the charts.
Call MakeGraphs("MultiPriceActual", "BondData", lngRowCheck)
Call MakeGraphs("MultiPriceNormalised", "Normalised", lngRowCheck)

'Sub that creates the chart, and adds the series of data for
'plotting.
Sub MakeGraphs(strChtTab As String, strWks As String, intRef As Long)

Dim cht As Chart
Dim i As Integer, intj As Integer

Set cht = ActiveWorkbook.Charts.Add
cht.ChartType = xlLine
cht.Name = strChtTab

cht.HasLegend = True
cht.Legend.Position = xlLegendPositionTop
cht.HasTitle = False
'more code that does the series adding and formatting.

Basically what happens is the first call works well, the chart is
created, and the series plotted. On the second call, the chartsheet is
created, but not filled with a 'skeleton' chart (it is blank), so when
the .haslengend property is set, the code falls down, as there is no
chart to set the property for.

I am sure i am missing something basic here, and can post more code if
required.

Many Thanks
Ian R

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
Invalid outside procedure (creating a PDF button as a macro) Neall Excel Worksheet Functions 0 April 30th 09 03:44 PM
Error when creating a stock chart from data in .CSV file Curious[_2_] Excel Discussion (Misc queries) 9 April 16th 08 02:20 AM
Creating An Event Procedure Les Stout[_2_] Excel Programming 4 October 4th 05 02:03 PM
Creating an event procedure question bhofsetz[_6_] Excel Programming 2 June 8th 05 07:03 PM
Error: The procedure number is out of range Van S. Mabrito Excel Programming 1 February 19th 04 11:33 AM


All times are GMT +1. The time now is 04:18 AM.

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

About Us

"It's about Microsoft Excel"