Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Avi Avi is offline
external usenet poster
 
Posts: 29
Default Update PivotChart Legands

Hi All,

I want to update Chart Legands for a PivotChart Using VBA. Currently
my pvtChart is based on Pivot that looks like
DefectSource Count
Code 10
Requirement 5
Design 2

and currently the Chart Legands Shows values as {Code , Requirement,
Design}. I wish to Change them to {Code (10) , Requirement (5), Design
(2)}.

I could do it using the below proc(added at the end of discussion) for
the charts that are NOT based on PivotTables.
But the same proc fails in line "Ser.XValues = arrLegand" if my source
data is based on any PivotTable. I am not even able to update that
manually because Axis Labels are not editable.

I am using XL2007, Please suggest if there is any way to acheive
this.

Any Help in this regard is highly appreciated.
Thanks,
Avinash

Code:
Sub UpdateLegand()
Dim arrTempXVal()
Dim arrTempVal()
Dim arrLegand()
Dim NumElements As Integer

Set Ser = ActiveChart.SeriesCollection(1)

NumElements = UBound(Ser.XValues)

ReDim arrTempXVal(0 To NumElements - 1)
ReDim arrTempVal(0 To NumElements - 1)
ReDim arrLegand(0 To NumElements - 1)

arrTempXVal = Ser.XValues
arrTempVal = Ser.Values

If InStr(1, arrTempXVal(1), "(", vbTextCompare) = 0 Then
For i = 1 To NumElements
arrLegand(i - 1) = arrTempXVal(i) & " (" & arrTempVal(i) &
") "
Next i
Ser.XValues = arrLegand ' Here it fails
End If
ActiveChart.SetElement (msoElementLegendRight)

End Sub
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicating PivotChart / Changing PivotChart data range BillG Charts and Charting in Excel 0 February 4th 09 08:56 PM
PivotChart Dominic Excel Discussion (Misc queries) 3 March 20th 06 05:38 PM
pivotchart Shin Charts and Charting in Excel 1 June 20th 05 01:01 AM
[help] asp & pivotchart ballball Excel Programming 0 August 18th 03 02:46 AM
REformatting PivotChart Jon Peltier[_3_] Excel Programming 1 August 8th 03 05:45 AM


All times are GMT +1. The time now is 10:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"