Attribute VB_Name = "SAMonthAndQuartGraph" Function MonthlySalesAmountTable(ByVal calc_result As Variant, ByVal file_path As String) Const HEADER_ROW As Long = 1 Const START_CELL As String = "A1" Dim wb As Workbook Dim ws As Worksheet Dim startCell As Range ' Open the workbook Set wb = Workbooks.Open(file_path) Set ws = wb.Sheets("Sales Analysis Monthly_Quartery") ' Write headers Set startCell = ws.Range(START_CELL) With startCell .Value = "Monthly Sales Amount in 2023" End With With startCell .Offset(1, 0).Value = "date" .Offset(1, 1).Value = "Monthly Sales" End With Set startCell = ws.Range("A3") Dim monthNames() As Variant monthNames = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") Dim monthly_sales As Variant monthly_sales = calc_result(2) For m = LBound(monthNames) To UBound(monthNames) startCell.Offset(m, 0).Value = monthNames(m) startCell.Offset(m, 1).Value = monthly_sales(m + 1) Next m ' Save and close the workbook ' wb.Close SaveChanges:=True End Function Function MonthlySalesAmountGraph(ByVal file_path As String) Dim wb As Workbook Dim ws As Worksheet Set wb = Workbooks.Open(file_path) Set ws = wb.Sheets("Sales Analysis Monthly_Quartery") Range("A2:B14").Select ' insert graph ActiveSheet.Shapes.AddChart2(332, xlLineMarkers).Select ActiveChart.SetSourceData Source:=Range("$A$2:$B$14") ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis) Selection.Format.TextFrame2.TextRange.Characters.Text = "Date range" Set cho = ws.ChartObjects(1) Set cht = cho.Chart ' update chart styling cht.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis) '# set your axis in a variable Set ax = cht.Axes(xlValue, xlPrimary) '# Make sure your axis HAS a title ax.HasTitle = True With ax.AxisTitle.Format.TextFrame2.TextRange .Characters.Text = "Primary Y-Axis" With .Characters(1, 14).ParagraphFormat .TextDirection = msoTextDirectionLeftToRight .Alignment = msoAlignCenter End With End With cho.Top = 0 cho.Left = 0 cho.Width = 400 cho.Height = 300 End Function Function MonthlySalesComissionTable(ByVal calc_result As Variant, ByVal file_path As String) Const HEADER_ROW As Long = 1 Const START_CELL As String = "F1" Dim wb As Workbook Dim ws As Worksheet Dim startCell As Range ' Open the workbook Set wb = Workbooks.Open(file_path) Set ws = wb.Sheets("Sales Analysis Monthly_Quartery") ' Write headers Set startCell = ws.Range(START_CELL) With startCell .Value = "Monthly Sales Comission in 2023" End With With startCell .Offset(1, 0).Value = "date" .Offset(1, 1).Value = "Monthly Sales Commission" End With Set startCell = ws.Range("F3") Dim monthNames() As Variant monthNames = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") monthly_commission = calc_result(4) For m = LBound(monthNames) To UBound(monthNames) startCell.Offset(m, 0).Value = monthNames(m) startCell.Offset(m, 1).Value = monthly_commission(m + 1) Next m ' Save and close the workbook ' wb.Close SaveChanges:=True End Function Function MonthlySalesComissionGraph(ByVal file_path As String) Dim wb As Workbook Dim ws As Worksheet Set wb = Workbooks.Open(file_path) Set ws = wb.Sheets("Sales Analysis Monthly_Quartery") ' insert graph ActiveSheet.Shapes.AddChart2(332, xlLineMarkers).Select ActiveChart.SetSourceData Source:=Range("$F$2:$G$14") ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis) Selection.Format.TextFrame2.TextRange.Characters.Text = "Date range chart2" Set cho = ws.ChartObjects(2) Set cht = cho.Chart ' update chart styling cht.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis) '# set your axis in a variable Set ax = cht.Axes(xlValue, xlPrimary) '# Make sure your axis HAS a title ax.HasTitle = True With ax.AxisTitle.Format.TextFrame2.TextRange .Characters.Text = "Primary Y-Axis" With .Characters(1, 14).ParagraphFormat .TextDirection = msoTextDirectionLeftToRight .Alignment = msoAlignCenter End With End With cho.Top = 0 cho.Left = 400 cho.Width = 400 cho.Height = 300 End Function Function Helloworld() Debug.Print "helloworld SalesAnalysisMonthAndQuartGraph" End Function