|
- Sub test2()
- Set shts = Sheets("实际")
- Set shtm = Sheets("目标")
- Dim cht As ChartObject, ws As Worksheet, ks As Date
- arr = shts.UsedRange
- r& = UBound(arr)
- ks = InputBox("请输入开始日期")
- If IsDate(ks) Then
- n& = 1
- Do While n < r
- n = n + 1
- If arr(n, 1) >= ks Then Exit Do
- Loop
- Application.ScreenUpdating = False
- Set ws = Sheets.Add
- With ws
- '.Name = "销售额"
- .[l1] = ks
- Set cht = ws.ChartObjects.Add(.[a5].Left, .[l5].Top, 720, 360)
- With cht.Chart
- .ChartStyle = 233
- .ChartType = xlLine
- .SeriesCollection.NewSeries
- .SeriesCollection(1).Values = shts.Range("F" & n & ":F" & r)
- .SeriesCollection(1).XValues = shts.Range("A" & n & ":A" & r)
- .SeriesCollection(1).Name = "实际"
- .SeriesCollection(1).Format.Line.Weight = 1.5
- .SeriesCollection.NewSeries
- .SeriesCollection(2).Values = shtm.Range("E" & n & ":E" & r)
- .SeriesCollection(2).XValues = shts.Range("A" & n & ":A" & r)
- .SeriesCollection(2).Name = "目标"
- .SeriesCollection(2).Format.Line.Weight = 1.5
- .Axes(xlCategory).TickLabels.NumberFormatLocal = "m-d;@"
- .HasTitle = True
- .ChartTitle.Text = "实际与目标销售额对比图"
- .ChartArea.Interior.Color = RGB(64, 64, 64)
- End With
- End With
- Application.ScreenUpdating = True
- Else
- MsgBox "请输入正确日期!"
- End If
- End Sub
复制代码 重做一个 |
评分
-
1
查看全部评分
-
|