Identify last datapoints in PivotChart

paradox715

New Member
Joined
Jan 14, 2008
Messages
13
I am running a PivotChart (a line chart) and I want to identify the last non-blank datapoint for each series. The problem is that in a PivotChart, each series has the same number of datapoints (i.e. 10) even though each of my series in reality is different in size ... it's just that the PivotTable has blanks for the last data points when not in use. To keep this simple in my example code below, the part I'm really just having trouble with is getting the SeriesCollection(1) passed into an array, so that I can check how many non-blanks there are... any tips?

Code:
Sub FinalPointMarker()
Dim myArray As Variant
Dim ValidCounter As Integer
Dim x as variant

Set x = ActiveChart.SeriesCollection(1)

'Having trouble generating an array from a series collection here ...
myArray() = x

'The following works ok if I had instead setup a simple array manually in the prior step ...
For i = LBound(myArray) To UBound(myArray)
If (myArray(i) <> "") Then
    ValidCounter = ValidCounter + 1
End If

Next i

MsgBox ValidCounter

End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You can assign the values from your series like this...

Code:
myArray = ActiveChart.SeriesCollection(1).Values

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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