Pages

Sunday, August 25, 2013

Show Country Flags as Markers on X Y Chart

If you want to display the country flags as markers on X Y Scatter Chart. Snapshot below:





Steps
1 Download the country flags and save them in a folder
2 Make sure you name the flags as labels or series name 
3 Run below macro

Sub custom_markers()
    Dim srs As Series
    Dim cht As Chart
    Dim mapfolder As String
    
    ' make sure you save the maps with series name
    mapfolder = "C:\Users\admin\Desktop\Flags\" ' folder in which i saved all the maps
    
        ' change chart name here
        Set cht = Sheets("Sheet1").ChartObjects("Chart 1").Chart
    
    ' download the maps or shapes and save them in a folder
    ' I have downloaded maps from this site : http://www.free-country-flags.com/flag_pack.php?id=1
    
        'run a loop  to import flags to markes and display them on charts
        
        For Each srs In cht.SeriesCollection
            srs.MarkerStyle = xlMarkerStylePicture
            srs.Format.Fill.UserPicture (mapfolder & srs.Name & ".png")
            srs.Format.Line.Visible = msoFalse
            srs.MarkerForegroundColorIndex = xlColorIndexNone
        Next srs

End Sub


Download working File  https://app.box.com/s/ulyhg0etinlsqlz88uyr

No comments:

Post a Comment