|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- With Sheet1
- Set Rng = .[a1].CurrentRegion.Offset(1)
- arr = Rng
- '客流占比
- Rng.Sort Rng(1), 1
- Set cht = .ChartObjects("图表 1")
- cht.Chart.ChartTitle.Text = "国美店日客流量部门占比示意图"
- a = Application.Transpose(.[c2].Resize(UBound(arr) - 1))
- b = Application.Transpose(.[b2].Resize(UBound(arr) - 1))
- With cht.Chart.SeriesCollection(1)
- .Values = a
- .XValues = b
- .HasDataLabels = True
- .HasLeaderLines = True
- .DataLabels.NumberFormat = "0.00%"
- .DataLabels.ShowCategoryName = True
- .DataLabels.ShowPercentage = True
- .DataLabels.Position = xlLabelPositionBestFit
- End With
- myname$ = ThisWorkbook.Path & "" & cht.Chart.ChartTitle.Text & ".jpeg"
- cht.Chart.Export Filename:=myname, FilterName:="jpeg"
- '客流分布
- Rng.Sort Rng(3), 2
- Set cht = .ChartObjects("图表 2")
- cht.Chart.ChartTitle.Text = "国美店日客流量部门分布示意图"
- a = Application.Transpose(.[c2].Resize(UBound(arr) - 1))
- b = Application.Transpose(.[b2].Resize(UBound(arr) - 1))
- With cht.Chart.SeriesCollection(1)
- .Values = a
- .XValues = b
- .Name = "客流量"
- .HasDataLabels = True
- .DataLabels.NumberFormat = "0"
- .DataLabels.Position = xlLabelPositionOutsideEnd
- End With
- myname$ = ThisWorkbook.Path & "" & cht.Chart.ChartTitle.Text & ".jpeg"
- cht.Chart.Export Filename:=myname, FilterName:="jpeg"
- '销售额
- Rng.Sort Rng(5), 1
- Set cht = .ChartObjects("图表 3")
- cht.Chart.ChartTitle.Text = "国美店日销售额排名"
- a = Application.Transpose(.[e2].Resize(UBound(arr) - 1))
- b = Application.Transpose(.[b2].Resize(UBound(arr) - 1))
- With cht.Chart.SeriesCollection(1)
- .Name = "实际销售额"
- .Values = a
- .XValues = b
- .HasDataLabels = True
- .DataLabels.NumberFormat = "0"
- .DataLabels.Position = xlLabelPositionOutsideEnd
- End With
- myname$ = ThisWorkbook.Path & "" & cht.Chart.ChartTitle.Text & ".jpeg"
- cht.Chart.Export Filename:=myname, FilterName:="jpeg"
- .[a2].Resize(UBound(arr), 5) = arr
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|