Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Creating Second Chart via Sub Procedure Error
Wow! Thank you Tushar!
Added in a line between the 2 calls that selected a cell, and it works.... Many Many Thanks. Ian |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Creating Second Chart via Sub Procedure Error
In article . com,
says... Wow! Thank you Tushar! Added in a line between the 2 calls that selected a cell, and it works.... Many Many Thanks. Ian You are welcome. Glad to be of help. -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Invalid outside procedure (creating a PDF button as a macro) | Excel Worksheet Functions | |||
Error when creating a stock chart from data in .CSV file | Excel Discussion (Misc queries) | |||
Creating Second Chart via Sub Procedure Error | Excel Programming | |||
Creating An Event Procedure | Excel Programming | |||
Creating an event procedure question | Excel Programming |