Team,
how can I call this macro (I would like to assing to shape in sheet, but now I don't see it):
If all code is placed as:
I see it and can assing "do_chart_4" to for example shape1.
Please give me advise or any comment how do resolve problem,
king regards,
PvK
how can I call this macro (I would like to assing to shape in sheet, but now I don't see it):
Code:
Public Sub CreateAChart(my_source As Range, my_location As ChartObject)
Dim co As ChartObject
Set co = my_location
co.Chart.ChartType = xlLine 'xlPie
co.Name = "ChartExample"
co.Chart.SeriesCollection.Add Source:=my_source, Rowcol:=xlColumns, SeriesLabels:=True, Categorylabels:=True
With co.Chart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlCategory, xlSecondary) = False
.HasAxis(xlValue, xlPrimary) = True
.HasAxis(xlValue, xlSecondary) = False
End With
With co.Chart.Axes(xlCategory)
.HasTitle = True
.AxisTitle.Caption = "Types"
.AxisTitle.Border.Weight = xlMedium
End With
With co.Chart.Axes(xlValue)
.HasTitle = True
With .AxisTitle
.Caption = "Quantity for 1999"
.Font.Size = 8
.Orientation = xlHorizontal
.Characters(14, 4).Font.Italic = True
.Border.Weight = xlMedium
End With
End With
co.Chart.Axes(xlCategory).CategoryNames = _
Array("a", "b", "c", "d", "e")
co.Chart.Axes(xlValue).CrossesAt = 50
co.Chart.Axes(xlValue).HasMajorGridlines = True 'pozioma
co.Chart.Axes(xlCategory).HasMajorGridlines = False 'pionowa
co.Chart.Axes(xlCategory).MajorTickMark = xlTickMarkCross
co.Chart.Axes(xlCategory).TickLabelPosition = _
xlTickLabelPositionNextToAxis
co.Chart.ChartArea.Interior.Color = RGB(255, 255, 255)
co.Chart.PlotArea.Interior.ColorIndex = 15
With co.Chart.Legend.LegendEntries(1).LegendKey
.Border.Weight = xlThick
End With
With co.Chart.SeriesCollection(1)
.MarkerSize = 10
.MarkerStyle = xlMarkerStyleDiamond
With .Points(2)
.MarkerSize = 20
.MarkerStyle = xlMarkerStyleCircle
End With
End With
End Sub
Private Sub do_chart_5()
Dim my_source As Range
Dim my_location As ChartObject
Set my_source = Worksheets("Sheet1").Range("A1:D6")
Set my_location = Worksheets("Sheet3").ChartObjects.Add(100, 100, 400, 300)
Call CreateAChart(my_source, my_location)
End Sub
If all code is placed as:
Code:
Function CreateAChart(my_source As Range, my_location As ChartObject)
...
..
.
End Function
Sub do_chart_4()
...
..
.
End Sub
I see it and can assing "do_chart_4" to for example shape1.
Please give me advise or any comment how do resolve problem,
king regards,
PvK