首页 > 解决方案 > 如何在 VBA 中从一种类型的 xlColumnStacked 更改为另一种类型的 xlColumnStacked?

问题描述

我正在尝试运行一个需要布局的图表,该布局不是 Excel 的主要布局。显然,即使布局完全不同,它们也具有相同的图表类型。

Public nome_grafico As String
Public nome_planilha_grafico As String
Public numeroTermicas As Integer




Sub cria_grafico()

    Dim graf_ativo As String

    nome_planilha_grafico = ActiveSheet.Name

    numeroTermicas = Worksheets(nome_planilha_grafico).Cells(1, 6).Value

    Worksheets(nome_planilha_grafico).Range(Cells(2, 1), Cells(numeroTermicas + 1, 2)).Select
    ActiveSheet.Shapes.AddChart2(297, xlColumnStacked).Select
    ActiveChart.SetSourceData Source:=Worksheets(nome_planilha_grafico).Range(Cells(2, 1), Cells(numeroTermicas + 1, 2))
    ActiveChart.ChartType = xlColumnStacked

    graf_ativo = ActiveChart.Name
    nome_grafico = Right(graf_ativo, (Len(graf_ativo) - (Len(nome_planilha_grafico) + 1)))

End Sub

标签: excelvbagraph

解决方案


推荐阅读