0

我是 VBA 的新手,我正在制作一个需要两个 y 轴并共享相同 x 轴的图表。我不太确定 xlvalue 和 xlcategory 的整个概念以及如何使用它们,我在网上使用了一些示例,但无法使其工作。我在下面粘贴了我的代码。提前致谢 !!

With Totalchart.Axes(xlCategory)
    .HasTitle = True
    .HasTitle = True
    .HasMajorGridlines = True
    .HasMinorGridlines = True
    With .AxisTitle
        .Caption = "Time (min)"
        .Font.Name = "bookman"
        .Font.Size = 10
    End With
End With

With Totalchart.Axes(xlValue)
    '.CategoryType = xlAutomatic
    .HasTitle = True
    .HasTitle = True
    .HasMajorGridlines = True
    .HasMinorGridlines = True
    .MinimumScale = 0
    With .AxisTitle
        .Caption = "caption1"
        .Font.Name = "bookman"
        .Font.Size = 10
    End With
End With

With Totalchart.Axes(xlValue, xlSecondary)
    '.CategoryType = xlAutomatic
    .HasTitle = True
    .HasTitle = True
    .MinimumScale = 0
    With .AxisTitle
        .Caption = "Caption2"
        .Font.Name = "bookman"
        .Font.Size = 10
    End With
End With
4

1 回答 1

0

.AxisTitle.Text并且.AxisTitle.Caption略有不同。请参阅此MSDN 文档

在 Excel 2007 中,将 设置.AxisTitle.Text为您的轴标题,如下所示:

With Totalchart.Axes(xlValue, xlSecondary)
    .HasTitle = True
    .MinimumScale = 0
    With .AxisTitle
        .Text = "Axis Title"
        .Font.Name = "bookman"
        .Font.Size = 10
    End With
End With

确保在此代码之前启用了辅助轴。这样的事情取决于您的系列收藏。

With Totalchart
  .SeriesCollection(2).AxisGroup = xlSecondary
  .HasAxis(xlValue, xlSecondary) = True
  .Axes(xlCategory, xlSecondary).CategoryType = xlAutomatic
End With

另外,尝试记录自己的宏,手动创建辅助轴并研究代码。可能对您的命名有所帮助。

于 2013-10-29T15:32:16.140 回答