Sub DHSCreateChart()
Dim UserRangeOrders As Range
Dim UserRangeRevenue As Range
Dim UserRangeProfit As Range
Dim W As Long, H As Long
Dim TopPosition As Long, LeftPosition As Long, RightPosition As Long
Dim ChtObj As ChartObject
Set UserRangeOrders = Range("$A$17:$C$22")
Set UserRangeRevenue = Range("$A$17:$A$22, $E$17:$F$22")
Set UserRangeProfit = Range("$A$17:$A$22, $H$17:$I$22")
Application.ScreenUpdating = False
Sheets("DHS vs Op Plan").Activate
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:="DHS Var Graphs"
With ActiveChart
.SetSourceData UserRangeOrders
.HasTitle = True
.ChartType = xlColumnClustered
.ChartTitle.Characters.Text = "DHS Order Variance ($M)"
.Axes(xlValue).HasMajorGridlines = False
.Legend.Position = xlLegendPositionBottom
.Legend.Border.LineStyle = x1None
.Axes(xlValue).TickLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.ApplyDataLabels xlDataLabelsShowValue
.SeriesCollection(1).DataLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.SeriesCollection(2).DataLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.PlotArea.Fill.OneColorGradient Style:=msoGradientHorizontal, Variant:=1, _
Degree:=0.331364919508659
.PlotArea.Fill.Visible = True
.PlotArea.Fill.ForeColor.SchemeColor = 40
.Axes(xlCategory).TickLabelPosition = xlLow
.Deselect
End With
Sheets("DHS vs Op Plan").Activate
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:="DHS Var Graphs"
With ActiveChart
.SetSourceData UserRangeRevenue
.HasTitle = True
.ChartType = xlColumnClustered
.ChartTitle.Characters.Text = "DHS Revenue Variance ($M)"
.Axes(xlValue).HasMajorGridlines = False
.Legend.Position = xlLegendPositionBottom
.Legend.Border.LineStyle = x1None
.Axes(xlValue).TickLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.ApplyDataLabels xlDataLabelsShowValue
.SeriesCollection(1).DataLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.SeriesCollection(2).DataLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.PlotArea.Fill.OneColorGradient Style:=msoGradientHorizontal, Variant:=1, _
Degree:=0.331364919508659
.PlotArea.Fill.Visible = True
.PlotArea.Fill.ForeColor.SchemeColor = 40
.Axes(xlCategory).TickLabelPosition = xlLow
.Deselect
End With
Sheets("DHS vs Op Plan").Activate
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:="DHS Var Graphs"
With ActiveChart
.SetSourceData UserRangeProfit
.HasTitle = True
.ChartType = xlColumnClustered
.ChartTitle.Characters.Text = "DHS Profit Variance ($M)"
.Axes(xlValue).HasMajorGridlines = False
.Legend.Position = xlLegendPositionBottom
.Legend.Border.LineStyle = x1None
.Axes(xlValue).TickLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.ApplyDataLabels xlDataLabelsShowValue
.SeriesCollection(1).DataLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.SeriesCollection(2).DataLabels.NumberFormat = "#,##0.0,,_);[Red](#,##0.0,,)"
.PlotArea.Fill.OneColorGradient Style:=msoGradientHorizontal, Variant:=1, _
Degree:=0.331364919508659
.PlotArea.Fill.Visible = True
.PlotArea.Fill.ForeColor.SchemeColor = 40
.Axes(xlCategory).TickLabelPosition = xlLow
.Deselect
End With
W = ActiveChart.Parent.Width - 5
H = ActiveChart.Parent.Height - 5
TopPosition = 1
LeftPosition = 10
For Each ChtObj In ActiveSheet.ChartObjects
ChtObj.Width = W
ChtObj.Height = H
ChtObj.Top = TopPosition
ChtObj.Left = LeftPosition
TopPosition = TopPosition + ChtObj.Height
Next ChtObj
Application.ScreenUpdating = True
End Sub
Bookmarks