Invalid Use of Property - creating excel chart

  • Thread starter Thread starter Santiago Gomez
  • Start date Start date
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?
 
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
 
replaced it with this...

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

and it works. sorry, real newbie.
 
Back
Top