'===================ABV PROJECT====================== '===================MODULE 1 ======================= Sub main () 'you can edit this macro to execute any command when loading this workbook 'next line call the routine that fill the sheet call absmain () End Sub 'Function not used if run inside abs (replaced by a builtin function) Sub absnc(row,col,formula) Cells(row,col).Formula=formula End sub 'Function not used if run inside abs (replaced by a builtin function) Sub absnc(row,col,formula) Cells(row,col).Formula=formula End sub 'Function not used if run inside abs (replaced by a builtin function) Sub absnc(row,col,formula) Cells(row,col).Formula=formula End sub Sub absmain() 'Do not edit this macro, changes will not be saved with the workbook!!! Dim objchart As Object Dim objbutton As Object Worksheets(1).Name = "Bar" Worksheets(2).Name = "PIE" Worksheets(3).Name = "LINE" Worksheets(1).Activate Columns("A").ColumnWidth = 5.714286 Columns("B").ColumnWidth = 5.714286 absnc(2,2,"'Bar Chart ") Cells(2,2).Font.Size = 18 absnc(9,3,"'Serie 1") Cells(9,3).Borders.LineStyle = xlLineStyleContinuous Cells(9,3).HorizontalAlignment = xlCenter absnc(9,4,"'Serie 2") Cells(9,4).Borders.LineStyle = xlLineStyleContinuous Cells(9,4).HorizontalAlignment = xlCenter absnc(10,2,"1") absnc(10,3,"=+B10*B10") Cells(10,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(10,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(10,3).HorizontalAlignment = xlCenter absnc(10,4,"=C10-B10") Cells(10,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(10,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(10,4).HorizontalAlignment = xlCenter absnc(11,2,"=+1+B10") absnc(11,3,"=+B11*B11") Cells(11,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(11,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(11,3).HorizontalAlignment = xlCenter absnc(11,4,"=C11-B11") Cells(11,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(11,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(11,4).HorizontalAlignment = xlCenter absnc(12,2,"=+1+B11") absnc(12,3,"=+B12*B12") Cells(12,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(12,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(12,3).HorizontalAlignment = xlCenter absnc(12,4,"=C12-B12") Cells(12,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(12,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(12,4).HorizontalAlignment = xlCenter absnc(13,2,"=+1+B12") absnc(13,3,"=+B13*B13") Cells(13,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(13,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(13,3).HorizontalAlignment = xlCenter absnc(13,4,"=C13-B13") Cells(13,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(13,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(13,4).HorizontalAlignment = xlCenter absnc(14,2,"=+1+B13") absnc(14,3,"=+B14*B14") Cells(14,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(14,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(14,3).HorizontalAlignment = xlCenter absnc(14,4,"=C14-B14") Cells(14,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(14,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(14,4).HorizontalAlignment = xlCenter absnc(15,2,"=+1+B14") absnc(15,3,"=+B15*B15") Cells(15,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(15,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(15,3).HorizontalAlignment = xlCenter absnc(15,4,"=C15-B15") Cells(15,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(15,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(15,4).HorizontalAlignment = xlCenter absnc(16,2,"=+1+B15") absnc(16,3,"=+B16*B16") Cells(16,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(16,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(16,3).HorizontalAlignment = xlCenter absnc(16,4,"=C16-B16") Cells(16,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(16,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(16,4).HorizontalAlignment = xlCenter absnc(17,2,"=+1+B16") absnc(17,3,"=B17*B17") Cells(17,3).Borders(xlEdgeBottom).LineStyle = xlLineStyleContinuous Cells(17,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(17,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(17,3).HorizontalAlignment = xlCenter absnc(17,4,"=C17-B17") Cells(17,4).Borders(xlEdgeBottom).LineStyle = xlLineStyleContinuous Cells(17,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(17,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(17,4).HorizontalAlignment = xlCenter absnc(22,3,"'Y axis label:") absnc(22,4,"'value") absnc(23,3,"'X axis label:") absnc(23,4,"'item") Set objchart = Worksheets("Bar").ChartObjects.Add(287,102,397,273) objchart.Activate ActiveChart.ChartType = xlColumnClustered ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(1).XValues = Range("B10:B17") ActiveChart.SeriesCollection(1).Name = "=C9" ActiveChart.SeriesCollection(1).Values = Range("C10:C17") ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(2).Name = "=D9" ActiveChart.SeriesCollection(2).Values = Range("D10:D17") ActiveChart.HasTitle = True ActiveChart.ChartTitle.Text = "=B2" ActiveChart.Axes(xlCategory).HasTitle = True ActiveChart.Axes(xlCategory).AxisTitle.Text = "=D23" ActiveChart.Axes(xlValue ).HasTitle = True ActiveChart.Axes(xlValue ).AxisTitle.Text = "=D22" Worksheets(2).Activate absnc(1,1,"'Pie Chart ") Cells(1,1).Font.Size = 18 absnc(2,1,"'Labels") absnc(2,2,"'Data") absnc(3,1,"'one") absnc(3,2,"3") absnc(4,1,"'two") absnc(4,2,"3") absnc(5,1,"'three") absnc(5,2,"8") absnc(6,1,"'four") absnc(6,2,"2") absnc(7,1,"'five") absnc(7,2,"6") absnc(8,1,"'six") absnc(8,2,"1") absnc(9,1,"'seven") absnc(9,2,"4") absnc(10,1,"'height") absnc(10,2,"2") Set objchart = Worksheets("PIE").ChartObjects.Add(211,12,528,461) objchart.Activate ActiveChart.ChartType = xlPie ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(1).XValues = Range("A3:A10") ActiveChart.SeriesCollection(1).Name = "'Serie2" ActiveChart.SeriesCollection(1).Values = Range("B3:B10") ActiveChart.HasTitle = True ActiveChart.ChartTitle.Text = "=A1" Worksheets(3).Activate Columns("A").ColumnWidth = 4.428571 Columns("B").ColumnWidth = 6.857143 absnc(1,1,"'XY Chart ") Cells(1,1).Font.Size = 18 absnc(9,3,"'Serie 1") Cells(9,3).Borders.LineStyle = xlLineStyleContinuous Cells(9,3).HorizontalAlignment = xlCenter absnc(9,4,"'Serie 2") Cells(9,4).Borders.LineStyle = xlLineStyleContinuous Cells(9,4).HorizontalAlignment = xlCenter absnc(10,2,"1") absnc(10,3,"=B10*B10") Cells(10,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(10,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(10,3).HorizontalAlignment = xlCenter absnc(10,4,"=+C10-B10") Cells(10,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(10,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(10,4).HorizontalAlignment = xlCenter absnc(11,2,"=1+B10") absnc(11,3,"=B11*B11") Cells(11,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(11,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(11,3).HorizontalAlignment = xlCenter absnc(11,4,"=+C11-B11") Cells(11,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(11,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(11,4).HorizontalAlignment = xlCenter absnc(12,2,"=1+B11") absnc(12,3,"=B12*B12") Cells(12,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(12,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(12,3).HorizontalAlignment = xlCenter absnc(12,4,"=+C12-B12") Cells(12,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(12,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(12,4).HorizontalAlignment = xlCenter absnc(13,2,"=1+B12") absnc(13,3,"=B13*B13") Cells(13,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(13,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(13,3).HorizontalAlignment = xlCenter absnc(13,4,"=+C13-B13") Cells(13,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(13,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(13,4).HorizontalAlignment = xlCenter absnc(14,2,"=1+B13") absnc(14,3,"=B14*B14") Cells(14,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(14,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(14,3).HorizontalAlignment = xlCenter absnc(14,4,"=+C14-B14") Cells(14,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(14,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(14,4).HorizontalAlignment = xlCenter absnc(15,2,"=1+B14") absnc(15,3,"=B15*B15") Cells(15,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(15,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(15,3).HorizontalAlignment = xlCenter absnc(15,4,"=+C15-B15") Cells(15,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(15,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(15,4).HorizontalAlignment = xlCenter absnc(16,2,"=1+B15") absnc(16,3,"=B16*B16") Cells(16,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(16,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(16,3).HorizontalAlignment = xlCenter absnc(16,4,"=+C16-B16") Cells(16,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(16,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(16,4).HorizontalAlignment = xlCenter absnc(17,2,"=1+B16") absnc(17,3,"=B17*B17") Cells(17,3).Borders(xlEdgeBottom).LineStyle = xlLineStyleContinuous Cells(17,3).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(17,3).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(17,3).HorizontalAlignment = xlCenter absnc(17,4,"=+C17-B17") Cells(17,4).Borders(xlEdgeBottom).LineStyle = xlLineStyleContinuous Cells(17,4).Borders(xlEdgeRight).LineStyle = xlLineStyleContinuous Cells(17,4).Borders(xlEdgeLeft).LineStyle = xlLineStyleContinuous Cells(17,4).HorizontalAlignment = xlCenter absnc(22,3,"'Y axis label:") absnc(22,4,"'value") absnc(23,3,"'X axis label:") absnc(23,4,"'x data") Set objchart = Worksheets("LINE").ChartObjects.Add(273,37,431,344) objchart.Activate ActiveChart.ChartType = xlLine ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(1).XValues = Range("B10:B17") ActiveChart.SeriesCollection(1).Name = "=C9" ActiveChart.SeriesCollection(1).Values = Range("C10:C17") ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(2).Name = "=D9" ActiveChart.SeriesCollection(2).Values = Range("D10:D17") ActiveChart.HasTitle = True ActiveChart.ChartTitle.Text = "=A1" ActiveChart.Axes(xlCategory).HasMajorGridlines = True ActiveChart.Axes(xlCategory).HasTitle = True ActiveChart.Axes(xlCategory).AxisTitle.Text = "=D23" ActiveChart.Axes(xlValue).HasMajorGridlines = True ActiveChart.Axes(xlValue ).HasTitle = True ActiveChart.Axes(xlValue ).AxisTitle.Text = "=D22" ActiveChart.Axes(xlValue ).MinimumScale = 0.000000 ActiveChart.Axes(xlValue ).MaximumScale = 50.000000 ActiveChart.Axes(xlValue ).MajorUnit = 10.000000 ActiveChart.Axes(xlCategory ).MinimumScale = 2.000000 ActiveChart.Axes(xlCategory ).MaximumScale = 7.000000 Worksheets(3).Activate End Sub