Adding chart title to chart - VBA

Kaps_mr2

Well-known Member
Joined
Jul 5, 2008
Messages
1,589
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to add a title to my radar graph but keep getting an error on the line in yellow. Can someone explain why pls ? thank you.

kind regards
Kaps


Rich (BB code):
 current_question = output_workbook.Sheets(sheet_name).Range("o2").Offset(0, c).Value
       
         Set chart_output_range = output_workbook.Sheets(sheet_name).Range("a5").Offset(((c - 1) * 7) + 1, 1).Resize(5, 6)
         Set chart_data_range = output_workbook.Worksheets(sheet_name).Range("o1").Offset(last_row_of_source_data + 2, c).Resize(5, 1)
        
        
        With output_workbook.Sheets(sheet_name).ChartObjects.Add _
        (Left:=chart_output_range.Left, Width:=chart_output_range.Width, Top:=chart_output_range.Top, Height:=chart_output_range.Height)
          .Chart.SetSourceData Source:=chart_data_range
        .Chart.ChartType = xlRadar
 '       .ChartTitle.Text = current_question
        End With
 
Last edited by a moderator:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
You should ensure that the chart actually has a title first - .Chart.HasTitle = True
 
Upvote 0
You should ensure that the chart actually has a title first - .Chart.HasTitle = True
thanks RoryA - but even with this I still get an error - "object does not support this property or method"


VBA Code:
For c = 1 To number_of_questions_in_this_category
        
        current_question = output_workbook.Sheets(sheet_name).Range("o2").Offset(0, c).Value
        
        
         If (Int(c / 2) = c / 2) Then
            Set chart_output_range = output_workbook.Sheets(sheet_name).Range("g5").Offset(((c - 1) * 7) - 5, 1).Resize(10, 5)
         End If
        
           If (Int(c / 2) <> c / 2) Then
            Set chart_output_range = output_workbook.Sheets(sheet_name).Range("a5").Offset((c * 7) - 5, 1).Resize(10, 5)
         End If
        
         Set chart_data_range = output_workbook.Worksheets(sheet_name).Range("o1").Offset(last_row_of_source_data + 2, c).Resize(5, 1)
        
        
        With output_workbook.Sheets(sheet_name).ChartObjects.Add _
        (Left:=chart_output_range.Left, Width:=chart_output_range.Width, Top:=chart_output_range.Top, Height:=chart_output_range.Height)
          .Chart.SetSourceData Source:=chart_data_range
        .Chart.ChartType = xlRadar
        .Chart.HasLegend = False
        .Chart.HasTitle = True
        .ChartTitle.Text = current_question
        End With
        
    
        Next c
 
Upvote 0
You missed out the .Chart before .ChartTitle
 
Upvote 0
Solution
many thanks !!
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top