I created a Gantt Chart with the following code which I found here (http://support.microsoft.com/kb/q123260/)
Sub gantt_chart()
On Error Resume Next
Dim rge As Variant
Dim mn As Variant
Dim shtname As Variant
'defines the variables
rge = Selection.Address()
'get the cell address
mn = Selection.Offset(1, 1)
'return the min value for the scale
Title = InputBox("Please enter the title")
'Asks the user for title
shtname = ActiveSheet.Name
'retains the name of current sheet
Application.ScreenUpdating = False
'Turns screen updating off
Charts.Add
'Create a paper model chart
ActiveChart.ChartWizard Source:=Sheets(shtname).Range(rge), _
Gallery:=xlBar, Format:=3, PlotBy:=xlColumns, CategoryLabels _
:=1, SeriesLabels:=1, HasLegend:=1, Title:=Title, _
CategoryTitle:="", ValueTitle:="", _
ExtraTitle:=""
' Basic chart definition
ActiveChart.Legend.Delete
'deletes the legend
ActiveChart.SeriesCollection(1).Select
'activates series 1
With Selection.Border
.Weight = xlThin
.LineStyle = xlNone
End With
'definition for the border for series 1
Selection.InvertIfNegative = False
'turns Invert if negative to false
Selection.Interior.ColorIndex = xlNone
'indicates that the area is set to none
ActiveChart.PlotArea.Select
'select the chart plot area
ActiveChart.Axes(xlCategory).Select
'select axis(1)
With ActiveChart.Axes(xlCategory)
.ReversePlotOrder = True
.TickLabelSpacing = 1
.TickMarkSpacing = 1
.AxisBetweenCategories = True
End With
'axis 1 definition
ActiveChart.Axes(xlValue).Select
'select axis(2)
With ActiveChart.Axes(xlValue)
.MinimumScale = mn
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = False
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
' Axis(2) definition
End Sub
My start dates are all 2/23/11 thru 3/28/11 yet the chart area (timeline X axis) starts in Jan 2011.
So I extended my start dates out thru Aug 2011 thinking it would eliminate the unnecessary time in front of the earliest X axis date and instead it backed up the x axis to Nov 2010!
Is there something in the code that's telling it to put extraneous time in front of the earliest date?
Bookmarks