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:

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 :
        '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

No comments:

Post a Comment

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...