Running time error '91' The object variable or the block variable with has not been defined

Asked

Viewed 725 times

0

I do not know how to play very well with excel, I have to make a graph using buttons and gave this error

Sub logs_acumulador()
'
' logs_acumulador Macro
'

'
    ActiveChart.SetSourceData Source:=Range( _
        "db_performance.producao[[#All],[logs_acumulador]]")
    ActiveChart.SeriesCollection(1).XValues = "=Plan1!$A$5:$A$124"
End Sub

1 answer

2


You first need to add the chart so that it is recognized as an object and in the object you can configure the range from which the information comes:

Use a line similar to this one with the graph that best fits your data. In this case, it is a bar graph:

ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select

Complete code:

Sub logs_acumulador()
'
' logs_acumulador Macro
'

'
    ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select 'gráfico de barras
    ActiveChart.SetSourceData Source:=Range( _
        "db_performance.producao[[#All],[logs_acumulador]]")
    ActiveChart.SeriesCollection(1).XValues = "=Plan1!$A$5:$A$124"
End Sub
  • Now you’re giving another problem:

  • Now it is giving another problem:Sub rolinho_fardo() ' ' rolinho_fardo Macro ' ' Activesheet.Shapes.Addchart2(201, xlColumnClustered). Select 'chart 1 Activechart.Setsourcedata Source:=Range( _ // RUNTIME ERROR 1004 THE RANGE METHOD OF THE_GLOBAL OBJECT FAILED "db_performance.producao[[#All],[rolinho_fardo]]") // ERROR ON THAT LINE ALSO :( Activechart.Seriescollection(1). Xvalues = "=Plan1! $A$5:$A$124"
 ActiveWindow.ScrollColumn = 2
 ActiveWindow.ScrollColumn = 3
 ActiveWindow.ScrollRow = 2
 ActiveWindow.ScrollRow = 3
 End Sub

  • I think by the rules of StackOverflow You have to create another question because this is a new mistake. Can I help you if you create the question and detail what kind of mistakes one is having is 1004 and the second is? If my answer worked for this question error '91' can mark it as my answer as an answer to your question, I am working on my reputation. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.