Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
Ed Ed is offline
external usenet poster
 
Posts: 399
Default VBA: Can't set ChartTitle.Text??

My macro tells me it can't set the ChartTitle. "Unable to set the Text
property of the ChartTitle class". Any help. please?
Ed

Sub MakeNewScatterChart()

Dim wkb As Workbook
Dim wks As Worksheet
Dim LastRow As Long
Dim LastCol As Long
Dim colData As Long
Dim cht As Chart
Dim chtObj As ChartObject
Dim rngData As Range
Dim rngXval As Range
Dim rngSer As Range
Dim strTitle As String

' Get limits of data
Set wkb = ActiveWorkbook
Set wks = wkb.Sheets(1)
LastRow = wks.Range("A65536").End(xlUp).Row
LastCol = wks.Range("IV4").End(xlToLeft).Column

' Set data range
Set rngData = wks.Range(Cells(4, 1), Cells(LastRow, LastCol))

' Define X data range
Set rngXval = rngData.Columns(1)

For colData = 2 To LastCol
' Add new chart object
Set cht = wkb.Charts.Add
With cht
.ChartType = xlXYScatterSmoothNoMarkers
' Delete initial data series
Do While .SeriesCollection.Count 0
.SeriesCollection(1).Delete
Loop

' Add data series
With .SeriesCollection.NewSeries
Set rngSer = rngData.Columns(colData)
.Values = rngSer
.XValues = rngXval
strTitle = wks.Cells(2, colData)
End With

.ChartTitle.Text = strTitle '<<< Error Here


  #2   Report Post  
Posted to microsoft.public.excel.charting
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Can't set ChartTitle.Text??

Never mind. I found .HasTitle and made it True. Does fine now.
Ed

"Ed" wrote in message
...
My macro tells me it can't set the ChartTitle. "Unable to set the Text
property of the ChartTitle class". Any help. please?
Ed

Sub MakeNewScatterChart()

Dim wkb As Workbook
Dim wks As Worksheet
Dim LastRow As Long
Dim LastCol As Long
Dim colData As Long
Dim cht As Chart
Dim chtObj As ChartObject
Dim rngData As Range
Dim rngXval As Range
Dim rngSer As Range
Dim strTitle As String

' Get limits of data
Set wkb = ActiveWorkbook
Set wks = wkb.Sheets(1)
LastRow = wks.Range("A65536").End(xlUp).Row
LastCol = wks.Range("IV4").End(xlToLeft).Column

' Set data range
Set rngData = wks.Range(Cells(4, 1), Cells(LastRow, LastCol))

' Define X data range
Set rngXval = rngData.Columns(1)

For colData = 2 To LastCol
' Add new chart object
Set cht = wkb.Charts.Add
With cht
.ChartType = xlXYScatterSmoothNoMarkers
' Delete initial data series
Do While .SeriesCollection.Count 0
.SeriesCollection(1).Delete
Loop

' Add data series
With .SeriesCollection.NewSeries
Set rngSer = rngData.Columns(colData)
.Values = rngSer
.XValues = rngXval
strTitle = wks.Cells(2, colData)
End With

.ChartTitle.Text = strTitle '<<< Error Here




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



All times are GMT +1. The time now is 01:41 PM.

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"