|
修改一下,生成13个表,输出13个图,条形图直接用苹果表做模板
- Sub savechart()
- arr = Sheet1.UsedRange
- Set d = CreateObject("scripting.dictionary")
- For i% = 2 To UBound(arr)
- If arr(i, 3) <> "" Then d(arr(i, 3) & "" & arr(i, 4)) = d(arr(i, 3) & "" & arr(i, 4)) & " " & i
- Next i
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For Each sht In Sheets
- If sht.Name <> "Sheet1" And sht.Name <> "苹果" Then sht.Delete
- Next
- Set sht = Sheets("苹果")
- For Each x In d.keys
- ar = Split(d(x))
- ReDim brr(1 To UBound(ar), 1 To 9)
- With sht
- .[a2:k222].ClearContents
- For i = 1 To UBound(ar)
- For k% = 1 To 9
- brr(i, k) = arr(ar(i), k)
- Next k, i
- .[a2].Resize(i - 1, 9) = brr
- .[a2].Resize(i - 1, 9).Sort .[g2], 2
- .[a2].Offset(IIf(i > 20, 20, i)).Resize(99, 9).ClearContents
- Set cht = .ChartObjects(1)
- cht.Chart.SetSourceData Source:=.[f1].Resize(IIf(i > 20, 21, i), 2)
- cht.Chart.ChartTitle.Text = .[d2] & "手机销售TOP20机型"
- myname$ = ThisWorkbook.Path & "" & .[c2] & "_" & .[d2] & "TOP20.jpeg"
- cht.Chart.Export Filename:=myname, FilterName:="jpeg"
- If .[d2].Value = "苹果" Then
- crr = .[a2:k21]
- Else
- sht.Copy after:=Sheets(Sheets.Count)
- Sheets(Sheets.Count).Name = sht.[d2]
- End If
- End With
- Next
- sht.[a2:k21] = crr
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|