Hello,
I'm trying to build a customized Gantt chart on excel.
I have a template with task start dates (col B) and end dates (col C) followed by the 12 months of the year (cols E-P).
I have the code below to generate the task duration bars.
The difficulty Im having is figuring out how to position the start of the bar relative to the task start month (col B) and the end of the bar relative to the end month (col C).
If anyone has any ideas it would be appreciated.
Regards,
John.
I'm trying to build a customized Gantt chart on excel.
I have a template with task start dates (col B) and end dates (col C) followed by the 12 months of the year (cols E-P).
I have the code below to generate the task duration bars.
The difficulty Im having is figuring out how to position the start of the bar relative to the task start month (col B) and the end of the bar relative to the end month (col C).
If anyone has any ideas it would be appreciated.
Regards,
John.
VBA Code:
Sub CreateShapes2()
Dim Start_Diamond As Shape
Dim End_Diamond As Shape
Dim conn As Shape
Dim rngPlace As Excel.Range
'set reference to a worksheet
Set w = ActiveSheet
'add Start Diamond
Set rngPlace = w.Range("E4")
With rngPlace
Set Start_Diamond = w.Shapes.AddShape(msoShapeDiamond, 300.5, 35, 8.5, 9.6)
'Add end diamond
Set End_Diamond = w.Shapes.AddShape(4, 600.5, 35, 8.5, 9.6)
'Set the connector link
Set conn = w.Shapes.AddConnector(msoConnectorStraight, 15, 150, 15, 150)
conn.ConnectorFormat.BeginConnect Start_Diamond, 1
conn.ConnectorFormat.EndConnect End_Diamond, 1
conn.RerouteConnections
End With
End Sub