I managed to work it out, the code looks like this:
Sub Gantt_Chart()
RiSoftGantt.Show
'Define the variables.
Dim ValueAxisMinValue As Date
Dim Title As String, aChart As Chart
'Store the location of the data as a string.
'Store the start date for the chart.
ValueAxisMinValue = Sheets("Schema").Range("B3").Value
'Ask user for the Chart title.
Title = InputBox("Ange titeln på schemat")
If Title = vbNullString Then
Exit Sub
End If
'Store the sheet name.
'shtname = ActiveSheet.name
'Turn off screen updating.
Application.ScreenUpdating = False
'Create a chart located on a chart sheet.
Set aChart = Charts.Add
With aChart
.ChartWizard Source:=Sheets("Schema").Range("A2:D7"), _
Gallery:=xlBar, Format:=3, PlotBy:=xlColumns, _
CategoryLabels:=1, SeriesLabels:=1, HasLegend:=1, _
Title:=Title, CategoryTitle:="", ValueTitle:="", _
ExtraTitle:=""
'Remove the legend.
.Legend.Delete
'Create and format the series.
With .SeriesCollection(1)
With .Border
.Weight = xlThin
.LineStyle = xlNone
End With
.InvertIfNegative = False
.Interior.ColorIndex = xlNone
End With
'Modify the category (x) axis.
With .Axes(xlCategory)
.ReversePlotOrder = True
.TickLabelSpacing = 1
.TickMarkSpacing = 1
.AxisBetweenCategories = True
End With
'Modify the value (y) axis.
With .Axes(xlValue)
.MinimumScale = ValueAxisMinValue
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = False
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
End With
'Turn screen updating back on.
Application.ScreenUpdating = True
End Sub
the RiSoftGantt.Show is a userform which takes value from the userform and paste it in range "A3:D7"
Thank you.
Bookmarks