Hi,
I have a chart in an Excel dashboard with data from different countries that looks like this:
Country Chart.jpg
This is a simple bar pivotchart and I've just edited each data bar with a custom picture fill of the series' corresponding flag. The flag images are stored on my hard drive as, for example, "France.gif", "UK.gif" etc.
However, when the data is manipulated and a new country is added to the data, the images all move and, for instance, Germany's flag will be on the UK data bar,UK flag will move to Italy etc. Is there any way to permanently tie a picture to a particular data series?
Some investigation has led me to see that it is the data point values that I need to change the fill picture of and I have managed to get some code together to pull the names out of each data point in the chart:
This just gives me a message with each country in the chart but I want to try and then use this name to make the corresponding flag always fill the bar in the chart for that data point. Have tried:
But I get 'object required' error as I'm not sure of the right sytax to use here. Can anyone help with some code to fill the chart bar with a picture based on the data point name which is just going to be a flag of that country?
I have a chart in an Excel dashboard with data from different countries that looks like this:
Country Chart.jpg
This is a simple bar pivotchart and I've just edited each data bar with a custom picture fill of the series' corresponding flag. The flag images are stored on my hard drive as, for example, "France.gif", "UK.gif" etc.
However, when the data is manipulated and a new country is added to the data, the images all move and, for instance, Germany's flag will be on the UK data bar,UK flag will move to Italy etc. Is there any way to permanently tie a picture to a particular data series?
Some investigation has led me to see that it is the data point values that I need to change the fill picture of and I have managed to get some code together to pull the names out of each data point in the chart:
Code:
Dim ChartCountries As Variant
Dim CountryName As Variant
ChartCountries = ActiveChart.SeriesCollection(1).XValues
For Each CountryName In ChartCountries
Msgbox CountryName
End With
Next
This just gives me a message with each country in the chart but I want to try and then use this name to make the corresponding flag always fill the bar in the chart for that data point. Have tried:
Code:
For Each CountryName In ChartCountries
With CountryName.Format.Fill
.Visible = msoTrue
.UserPicture "C:\Users\JMC\Documents\Flags\" & CountryName & ".gif"
.TextureTile = msoFalse
End With
Next
But I get 'object required' error as I'm not sure of the right sytax to use here. Can anyone help with some code to fill the chart bar with a picture based on the data point name which is just going to be a flag of that country?