Set categories names from data encoded in a separator-delimited string.
object.SetCategoriesFromString categories
You can set the categories in a chart with categories names encoded in a string (i.e. the categories argument). The string must be formatted as a list of names, two consecutive names must be separated by a separator character that can be specified with the SetSeparators method.
Here is an example of categories names encoded in a string with the character ";" as separator.
myEncodedString= "North America;South America;Europe;Middle East;Asia"
The string argument categories is parsed by the chart object according to the separator characters specified to the chart object (see the SetSeparators method for specifying separator characters and rules).
The ";" character is the default separator character.
The following VBScript code shows how to store the series and categories of the table below using the SetCategoriesFromString method. This table has two series named "Year 2006" and "Year 2007". The categories are "North America", "South America", "Europe", "Middle East" and "Asia".
|
||||||||||||||||||
'Let's build the categories string with ";" as separator sep= ";" ignoremultseparators= true 'Before setting the series and categories, we must specify the separators chart.SetSeparators sep ignoremultseparators myString= "North America" & sep & "South America" & sep & "Europe" & sep & "Middle East" & sep & "Asia" 'Fill the chart with the categories stored in the myString variable chart.SetCategoriesFromString myString 'Add the first series "Year 2006" myString= "12" & sep & "7.5" & sep & "11.3" & sep & "9.2" & sep & "5.3" 'Fill the first series with the data stored in the myString variable chart.SetSeriesCaption 0, "Year 2006" chart.SetSeriesValuesFromString 0, myString 'Do the same way for the second series "Year 2007"
GetCategory Method | GetValuesCount Method | SetCategoriesFromArray Method | SetSeparators Method
Applies To: Chart Object