Dim LastRow As Long
Dim Rng1 As Range
Dim ShName As String
With ActiveSheet
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
Set Rng1 = .Range("A2:E" & LastRow)
ShName = .Name
End With
Charts.Add
With ActiveChart
.ChartType = xlLine
.HasTitle = True
.ChartTitle.Text = "CPU Utilization"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Duration of Run(hh:mm)" 'X axis name
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "CPU Utilization (%)" 'y-axis name
.Legend.Position = xlLegendPositionBottom
.SetSourceData Source:=Rng1
.Location Where:=xlLocationAsObject, Name:=ShName
End With
我想在上面的代码中添加numberformat我尝试下面的代码,但没有工作(方法或数据未找到错误)
.NumberFormat = "[$-F400]h:mm:ss AM/PM"
.NumberFormat = "h:mm;@"
还要设置图形的宽度和高度,并在格式轴上添加千位显示单位。请。为此提供解决方案。
答案 0 :(得分:0)
对于数字格式,您必须将数字格式指定给图表的某些子。例如:Axes(xlCategory).TickLabels.NumberFormat
对于差距,请参阅MSDN-ChartGroup.GapWidth Property
我不明白您希望如何以时间格式显示数千个,但千位分隔值的自定义格式如下所示"# ##0,00"
如果您想试验图表,我建议使用宏录制器。这就是我如何做到的。