Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Racir

Gráfico no excel

Recommended Posts

Racir

Estava a tentar desenhar um gráfico em função de dados de uma outra folha e dá o erro assinalado. Não percebo porquê. Podem dar-me uma ajuda?

Private Sub Grafico1_Click()

Dim Nitens, Nalunos As Integer

Grafico1.BackColor = QBColor(12)

Nitens = Range("AE1").Value

Nalunos = Range("E5").Value

ActiveSheet.Shapes.AddChart.Select

    ActiveChart.ChartType = xl3DColumnClustered

    ActiveChart.SetSourceData Source:=Sheets("Teste 1").Range(Cells(10, 5 + Nitens), Cells(9 + Nalunos, 5 + Nitens))

    ActiveChart.SeriesCollection(1).XValues = "='Teste 1'!$C$10:$C$15"

    ActiveChart.SeriesCollection(1).Select

    ActiveChart.SeriesCollection(1).ApplyDataLabels

    ActiveSheet.ChartObjects("Gráfico 3").Activate

   

    ActiveSheet.ChartObjects("Gráfico 3").Activate

    ActiveChart.SeriesCollection(1).Select

    ActiveSheet.ChartObjects("Gráfico 3").Activate

End Sub

Dá erro em ActiveChart.SetSourceData Source:=Sheets("Teste 1").Range(Cells(10, 5 + Nitens), Cells(9 + Nalunos, 5 + Nitens))

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.