VBA Code:
Sub CreateWaterfallChart()
Dim ws As Worksheet
Dim chtObj As ChartObject
Dim chtData As Range
Dim cht As Chart
' Set the worksheet where you want to create the chart
Set ws = ThisWorkbook.Sheets("Sheet1") ' Replace "Sheet1" with the desired worksheet name
' Define the range of data for the chart
Set chtData = ws.Range("A1:C10") ' Replace "A1:C10" with the range of data for the chart
' Create a chart object on the worksheet
Set chtObj = ws.ChartObjects.Add(Left:=100, Width:=400, Top:=100, Height:=300)
' Set the chart object's position and size
With chtObj
.Left = 100
.Top = 100
.Width = 400
.Height = 300
End With
' Set the chart object's chart type to waterfall
Set cht = chtObj.Chart
cht.ChartType = xlWaterfall
' Set the chart's data source
cht.SetSourceData chtData
' Format the chart as needed
' (e.g., axis labels, title, legend, etc.)
' Add any additional formatting or customization
' Display the chart
chtObj.Activate
End Sub