I have to amend a chart using VBA to plot column A(program) against column C(Date), at the moment it is mapped as column A(program) against column B(startsec).
the piece of VBA code that charts can be seen here
[pre]
[/pre]
in essense , I want the `
.Axes(xlValue).MinimumScale = l1
.Axes(xlValue).MaximumScale = l2
` to take values from the E column and not C column.
I would be grateful for any help/suggestions for this issue.
I have uploaded the excel chart in here
https://www.dropbox.com/s/fo8ipmjpgem46go/create_chart.xls
the piece of VBA code that charts can be seen here
[pre]
Code:
Sub createprocesscharts()
Dim sets(2, 365) As Long
Dim limits(2, 365) As Long
Dim dates(365) As String
c = 1
r = 2
Sheets("Sheet1").Select
dt = Cells(r, 5)
sets(1, c) = r
limits(1, c) = Cells(r, 2)
While (Cells(r, 5) <> "")
If Cells(r, 5) <> dt Then
sets(2, c) = r - 1
limits(2, c) = Cells(r - 1, 2)
dates(c) = Format(Cells(r - 1, 5), "ddd, d mmm yyyy")
dt = Cells(r, 5)
c = c + 1
sets(1, c) = r
limits(1, c) = Cells(r, 2)
End If
r = r + 1
Wend
sets(2, c) = r - 1
limits(2, c) = Cells(r - 1, 2)
dates(c) = Format(Cells(r - 1, 5), "ddd, d mmm yyyy")
For i = 1 To c
Debug.Print sets(1, i) & " " & sets(2, i) & " " & limits(1, i) & " " & limits(2, i) & " " & dates(i)
Call makechart(sets(1, i), sets(2, i), dates(i), limits(1, i), limits(2, i))
Next
End Sub
Sub makechart(r1 As Long, r2 As Long, dt As String, l1 As Long, l2 As Long)
Sheets("Sheet1").Select
rstart = "$A$" & r1
rend = "$C$" & r2
rg = "'Sheet1'!" & rstart & ":" & rend
ActiveSheet.Shapes.AddChart.Select
With ActiveChart
.SetSourceData Source:=Range(rg)
.ChartType = xlBarStacked
.Legend.Delete
.Axes(xlValue).MinimumScale = l1
.Axes(xlValue).MaximumScale = l2
.SeriesCollection(1).Interior.ColorIndex = xlNone
.Axes(xlCategory).TickLabelSpacing = 1
.Axes(xlCategory).TickLabels.Font.Bold = True
.Axes(xlCategory).TickLabels.Font.Size = 8
.Location Where:=xlLocationAsNewSheet, Name:=dt
End With
End Sub
in essense , I want the `
.Axes(xlValue).MinimumScale = l1
.Axes(xlValue).MaximumScale = l2
` to take values from the E column and not C column.
I would be grateful for any help/suggestions for this issue.
I have uploaded the excel chart in here
https://www.dropbox.com/s/fo8ipmjpgem46go/create_chart.xls