Tuesday, December 25, 2012

Macro to Replace Markers with Custom shapes On Charts


If you want to use custom shapes instead of showing the values with markers on charts. Snapshot below-

Image

Download Working File/Macro - https://www.box.com/s/02sfon6jloo7lpaj3s6c
 Steps to use -
  • Download the working File
  • Goto “Data” sheet . Change chart data as per your requirement , series name,etc.
  • Add custom shapes to excel sheet which you would like to show  instead of markers
  • Re size the shapes as per your requirement
  • Update the table in Col L and M on data sheet
  • Go to “Chart” sheet and click on Custom Markers 

Macro used to create Custom Markers -
Sub paste_custom_images_markers()
Dim srs As Series, j As Long, found As Range
For Each srs In Sheets(“Chart”).ChartObjects(“Chart 1″).Chart.SeriesCollection
Set found = Sheets(“Data”).Range(“l:l”).Find(srs.Name, LookIn:=xlValues)
If Not found Is Nothing Then
j = found.Row
Sheets(“Data”).Shapes(Sheets(“Data”).Range(“m” & j)).Copy
Sheets(“Chart”).ChartObjects(“Chart 1″).Activate
srs.Select
Selection.Paste
End If
Next
End Sub

Download Working File/Macro - https://www.box.com/s/02sfon6jloo7lpaj3s6c

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...