Invalid Use of Property - creating excel chart

S

Santiago Gomez

I am getting an "Invalid Use of Property" error when I run the code:

Public g_chtUsage As Excel.Chart
Public m_appXl As New Excel.Application
Public m_shUsageData As Excel.Worksheet
Public m_wbEnergy As Excel.Workbook

Sub CreateChart()

Set g_chtUsage = m_wbEnergy.Charts.Add

With g_chtUsage
.ChartType = xlAreaStacked
.SetSourceData Source: m_shUsageData.Range ("A2:A30,B2:B30"), _
PlotBy:=xlColumns
End With
End Sub

It breaks at the .Range part.

Any ideas?
 
S

Santiago Gomez

I avoided the error by changing the range to ("A1:B44")

but now I would like the ability to pass a string with the total recordcount
so tat the range of the graph changes according with the number of rows.

What is the proper format for the string inclusion?

Source:=m_shUsageData.Range("A1:E"&iCount&"), _

I get an error with the above.

Am i missing something?

thanks
 
S

Santiago Gomez

replaced it with this...

Source:=m_shUsageData.Range("A1:E" & iCount & ""), _

and it works. sorry, real newbie.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top