Hia all
I am trying to make sparklines/microcharts and run into a problem..
How do i name the lines? (and group them afterwards?)
Here is my code:
-----------------------
Sub sparkline()
limit = 30
'Fill Range with random numbers
For Row = 1 To limit
Cells(Row, 10) = Rnd(100) * 100
Next Row
Set myDocument = Worksheets(1)
Range("C10").Select
cell_xpos = ActiveCell.Left
cell_ypos = ActiveCell.Top
cell_width = ActiveCell.Width
cell_height = ActiveCell.Height
xstep = cell_width / limit
ystep = (cell_height / 100)
x1 = cell_xpos
y1 = cell_ypos + cell_height
y_Start = cell_ypos + cell_height
For Row = 1 To limit
Cells(Row, 10).Select
Change = Cells(Row, 10).Value
x2 = x1 + xstep
y2 = y_Start - (ystep * Change)
With myDocument.Shapes.AddLine(x1, y1, x2, y2)
.Line.Weight = 0.5
.Line.ForeColor.RGB = RGB(50, 0, 128)
.ZOrder msoSendToBack
' .name="sparkline" & row '**** this doesn't work
' .Line.name="sparkline & row ' ** nor this
End With
x1 = x2
y1 = y2
Next Row
Range("A1").Select
End Sub
I am trying to make sparklines/microcharts and run into a problem..
How do i name the lines? (and group them afterwards?)
Here is my code:
-----------------------
Sub sparkline()
limit = 30
'Fill Range with random numbers
For Row = 1 To limit
Cells(Row, 10) = Rnd(100) * 100
Next Row
Set myDocument = Worksheets(1)
Range("C10").Select
cell_xpos = ActiveCell.Left
cell_ypos = ActiveCell.Top
cell_width = ActiveCell.Width
cell_height = ActiveCell.Height
xstep = cell_width / limit
ystep = (cell_height / 100)
x1 = cell_xpos
y1 = cell_ypos + cell_height
y_Start = cell_ypos + cell_height
For Row = 1 To limit
Cells(Row, 10).Select
Change = Cells(Row, 10).Value
x2 = x1 + xstep
y2 = y_Start - (ystep * Change)
With myDocument.Shapes.AddLine(x1, y1, x2, y2)
.Line.Weight = 0.5
.Line.ForeColor.RGB = RGB(50, 0, 128)
.ZOrder msoSendToBack
' .name="sparkline" & row '**** this doesn't work
' .Line.name="sparkline & row ' ** nor this
End With
x1 = x2
y1 = y2
Next Row
Range("A1").Select
End Sub