I am developing a panel in which there will be many diagrams, and as the data displayed on these diagrams changes, so will the number format. At that moment, when I am right now, I had a problem trying to get the required code format from the spreadsheet on which the data is based, in the middle of the cycle for all series of the diagram. Here's the code for now:
Sub FixLabels(whichchart As String)
Dim cht As Chart
Dim i, z As Variant
Dim seriesname, seriesfmt As String
Dim seriesrng As Range
Set cht = Sheets("Dashboard").ChartObjects(whichchart).Chart
For i = 1 To cht.SeriesCollection.Count
If cht.SeriesCollection(i).name = "#N/D" Then
cht.SeriesCollection(i).DataLabels.ShowValue = False
Else
cht.SeriesCollection(i).DataLabels.ShowValue = True
seriesname = cht.SeriesCollection(i).name
Debug.Print seriesname
, , , . .
: , , , , "int", , "#, #" "%" . . , :
Select Case seriesfmt
Case "int"
Cht.SeriesCollection(i).DataLabels.NumberFormat = "#"
Case "#,#"
Cht.SeriesCollection(i).DataLabels.NumberFormat = "#,###"
Case "%"
Cht.SeriesCollection(i).DataLabels.NumberFormat = "#.0%"
End Select
End If
Next i
, : . ! :
With Sheets("CxC").Range("K22:K180")
seriesfmt = .Find(seriesname).Offset(0, -1).Value
End With
, , "" . , With, Set , Matchheet Match, . !