首页 分享 Excel应用

Excel应用

来源:花匠小妙招 时间:2025-05-13 17:52

深夜,没有睡意。因为,再次发现VBA的魅力。

给出一组数据,如下:

可以绘制多少种Excel图表呢?

答案是以下70多种(Excel 2016实测):

这效果绝对炫酷,熬夜也值了。

以上Excel图表类型见下表,

VBA代码共享给有缘人:

Public Sub MonthlyCalc()

Application.ScreenUpdating = False

Dim Itemp As Integer

Dim ChartTypeArray() As Variant

Dim ChartCount As Integer

For Itemp = 1 To 12

Cells(4, Itemp + 2) = Cells(2, Itemp + 2) * Cells(3, Itemp + 2)

Cells(7, Itemp + 2) = Cells(5, Itemp + 2) * Cells(6, Itemp + 2)

Cells(10, Itemp + 2) = Cells(8, Itemp + 2) * Cells(9, Itemp + 2)

Cells(11, Itemp + 2) = Cells(4, Itemp + 2) + Cells(7, Itemp + 2) _

+ Cells(10, Itemp + 2)

Next Itemp

ChartTypeArray = Array(-4169, -4151, -4120, -4102, -4101, -4100, -4098, 1, 4, 5, 15, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, _

67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, _

102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112)

ChartCount = 1

Do While (ChartCount <= (UBound(ChartTypeArray) + 1))

Charts.Add

ActiveChart.ChartType = ChartTypeArray(ChartCount - 1)

ActiveChart.SetSourceData Source:=Sheets("chap5_2").Range( _

"A1:N1,A4:N4,A7:N7,A10:N10"), PlotBy:=xlRows

ActiveChart.Location Where:=xlLocationAsObject, Name:="charts2"

With ActiveChart

.HasTitle = True

.ChartTitle.Characters.Text = ChartTypeArray(ChartCount - 1) & "——月销售情况对比"

End With

With ActiveChart.Parent

.Left = 10 + Int(ChartCount / 15) * 356

If (ChartCount Mod 15 <> 0) Then

.Top = 222 * (ChartCount Mod 15)

Else

.Top = 222

End If

End With

ChartCount = ChartCount + 1

Loop

Application.ScreenUpdating = True

End Sub


相关知识

excel在统计中的应用PPT.ppt
excel玫瑰图怎么弄
excel图表应用技巧:美化雷达图,制作一朵小红花
Excel在计算群落生物多样性指数中的应用.pdf
excel表格怎么制作热力图
excel表格怎么花统计表
Excel企业员工花名册统计表,自带函数统计,图表显示万能应用
excel做数据地图(Excel数据地图怎么做)
比传统柱形图美观十倍,详解Excel玫瑰图的制作方法与应用
Excel折线图花型图表模板制作教程

网址: Excel应用 https://www.huajiangbk.com/newsview1946789.html

所属分类:花卉
上一篇: [Excel VBA]如何使用V
下一篇: 如何在 Excel 中创建图表

推荐分享