图w在x轴上的date

我有一个代码集根据单元格值自我更新x轴。 我希望这些值显示为date,但使用标准的文本types的格式(例如,我有风格月份年份,1月16日,作为我的x轴上的每个点)。 但是,因为用户正在input代码中引用的这些单元格的最小值和最大值,所以我只希望将其作为文本提取出来,以便此代码可以识别它并对其进行绘制。 我在下面标有**的行出现错误。 我不知道该怎么做。 谢谢!

With ActiveSheet.ChartObjects("Chart 2").chart Select Case Target.Address Case "$L$37" **.Axes(xlCategory).MaximumScale = Target.Value** Case "$L$38" .Axes(xlCategory).MinimumScale = Target.Value Case "$L$39" .Axes(xlCategory).MajorUnit = Target.Value Case "$O$37" .Axes(xlValue).MaximumScale = Target.Value Case "$O$38" .Axes(xlValue).MinimumScale = Target.Value Case "$O$39" .Axes(xlValue).MajorUnit = Target.Value End Select End With 

修改后的代码,目前我只是手动完成所有的单元格地址,只是为了确保图表正在更新,而且确实如此。

 Public Sub Update_Chart() With ActiveSheet.ChartObjects("Chart 2").Chart .Axes(xlCategory).MaximumScale = Range("$L$37") .Axes(xlCategory).MinimumScale = Range("$L$38") .Axes(xlCategory).MajorUnit = Range("$L$39") ' this line you can modifty to whatever format you want your axis to have, the user doesn't need to keep the format on the worksheet cell itself .Axes(xlCategory).TickLabels.NumberFormat = "mmm-yy" ' "[$-409]d-mmm-yy;@" .Axes(xlValue).MaximumScale = Range("$O$37") .Axes(xlValue).MinimumScale = Range("$O$38") .Axes(xlValue).MajorUnit = Range("$O$39") ' change to whatever format you want your Y-Axis you want .Axes(xlValue).TickLabels.NumberFormat = "mmm-yy" End With End Sub