Creating a code to read multiple sets of series data in an animated graph





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm trying to produce an animated graph with over 40 columns of data. The graph is to move through each set of data along the columns. My code is attached below and I keep getting errors on line 5.



Sub Chart1()


Application.ScreenUpdating = False

Worksheets("TR01db.vel").Activate

Worksheets("TR01db.vel").Activate
Worksheets("TR01db.vel").ChartObjects("Chart 1").SeriesCollection(1).XValues = Worksheets("TR01db.vel").Range(Cells(4, 1), Cells(1000, 1))
Worksheets("TR01db.vel").ChartObjects("Chart 1").SeriesCollection(1).Values = Worksheets("TR01db.vel").Range(Cells(4, 2), Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100

Worksheets("TR01db.vel").ChartObjects(1).SeriesCollection(1).XValues = Worksheets("TR01db.vel").Range(Cells(4, 1), Cells(1000, 1))
Worksheets("TR01db.vel").ChartObjects(1).SeriesCollection(1).Values = Worksheets("TR01db.vel").Range(Cells(4, 2 + k), Cells(1000, 2 + k))

Next k

BeforeExit:
Set rValues = Nothing
Set rCell = Nothing

Exit Sub
ErrorHandle:
MsgBox Err.Description & " Procedure Chart1"
Resume BeforeExit
End Sub









share|improve this question

























  • What is the specific error you get?

    – BigBen
    Jan 3 at 4:30











  • Run-Time error "438''

    – Rachel Southey
    Jan 3 at 5:18


















0















I'm trying to produce an animated graph with over 40 columns of data. The graph is to move through each set of data along the columns. My code is attached below and I keep getting errors on line 5.



Sub Chart1()


Application.ScreenUpdating = False

Worksheets("TR01db.vel").Activate

Worksheets("TR01db.vel").Activate
Worksheets("TR01db.vel").ChartObjects("Chart 1").SeriesCollection(1).XValues = Worksheets("TR01db.vel").Range(Cells(4, 1), Cells(1000, 1))
Worksheets("TR01db.vel").ChartObjects("Chart 1").SeriesCollection(1).Values = Worksheets("TR01db.vel").Range(Cells(4, 2), Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100

Worksheets("TR01db.vel").ChartObjects(1).SeriesCollection(1).XValues = Worksheets("TR01db.vel").Range(Cells(4, 1), Cells(1000, 1))
Worksheets("TR01db.vel").ChartObjects(1).SeriesCollection(1).Values = Worksheets("TR01db.vel").Range(Cells(4, 2 + k), Cells(1000, 2 + k))

Next k

BeforeExit:
Set rValues = Nothing
Set rCell = Nothing

Exit Sub
ErrorHandle:
MsgBox Err.Description & " Procedure Chart1"
Resume BeforeExit
End Sub









share|improve this question

























  • What is the specific error you get?

    – BigBen
    Jan 3 at 4:30











  • Run-Time error "438''

    – Rachel Southey
    Jan 3 at 5:18














0












0








0








I'm trying to produce an animated graph with over 40 columns of data. The graph is to move through each set of data along the columns. My code is attached below and I keep getting errors on line 5.



Sub Chart1()


Application.ScreenUpdating = False

Worksheets("TR01db.vel").Activate

Worksheets("TR01db.vel").Activate
Worksheets("TR01db.vel").ChartObjects("Chart 1").SeriesCollection(1).XValues = Worksheets("TR01db.vel").Range(Cells(4, 1), Cells(1000, 1))
Worksheets("TR01db.vel").ChartObjects("Chart 1").SeriesCollection(1).Values = Worksheets("TR01db.vel").Range(Cells(4, 2), Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100

Worksheets("TR01db.vel").ChartObjects(1).SeriesCollection(1).XValues = Worksheets("TR01db.vel").Range(Cells(4, 1), Cells(1000, 1))
Worksheets("TR01db.vel").ChartObjects(1).SeriesCollection(1).Values = Worksheets("TR01db.vel").Range(Cells(4, 2 + k), Cells(1000, 2 + k))

Next k

BeforeExit:
Set rValues = Nothing
Set rCell = Nothing

Exit Sub
ErrorHandle:
MsgBox Err.Description & " Procedure Chart1"
Resume BeforeExit
End Sub









share|improve this question
















I'm trying to produce an animated graph with over 40 columns of data. The graph is to move through each set of data along the columns. My code is attached below and I keep getting errors on line 5.



Sub Chart1()


Application.ScreenUpdating = False

Worksheets("TR01db.vel").Activate

Worksheets("TR01db.vel").Activate
Worksheets("TR01db.vel").ChartObjects("Chart 1").SeriesCollection(1).XValues = Worksheets("TR01db.vel").Range(Cells(4, 1), Cells(1000, 1))
Worksheets("TR01db.vel").ChartObjects("Chart 1").SeriesCollection(1).Values = Worksheets("TR01db.vel").Range(Cells(4, 2), Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100

Worksheets("TR01db.vel").ChartObjects(1).SeriesCollection(1).XValues = Worksheets("TR01db.vel").Range(Cells(4, 1), Cells(1000, 1))
Worksheets("TR01db.vel").ChartObjects(1).SeriesCollection(1).Values = Worksheets("TR01db.vel").Range(Cells(4, 2 + k), Cells(1000, 2 + k))

Next k

BeforeExit:
Set rValues = Nothing
Set rCell = Nothing

Exit Sub
ErrorHandle:
MsgBox Err.Description & " Procedure Chart1"
Resume BeforeExit
End Sub






excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 4:26









BigBen

7,0402719




7,0402719










asked Jan 3 at 4:24









Rachel SoutheyRachel Southey

62




62













  • What is the specific error you get?

    – BigBen
    Jan 3 at 4:30











  • Run-Time error "438''

    – Rachel Southey
    Jan 3 at 5:18



















  • What is the specific error you get?

    – BigBen
    Jan 3 at 4:30











  • Run-Time error "438''

    – Rachel Southey
    Jan 3 at 5:18

















What is the specific error you get?

– BigBen
Jan 3 at 4:30





What is the specific error you get?

– BigBen
Jan 3 at 4:30













Run-Time error "438''

– Rachel Southey
Jan 3 at 5:18





Run-Time error "438''

– Rachel Southey
Jan 3 at 5:18












1 Answer
1






active

oldest

votes


















1














A ChartObject is just a "container" for a Chart, so you need something more like:



Worksheets("TR01db.vel").ChartObjects("Chart 1").Chart.SeriesCollection(1).XValues 'etc


A lot of repetition could be avoided by using some variables:



Sub Chart1()

Dim ws As WorkSheet, ser as Series
Application.ScreenUpdating = True

Set ws = ThisWorkbook.Worksheets("TR01db.vel")

With ws
.Activate
Set ser = .ChartObjects("Chart 1").Chart.SeriesCollection(1)
ser.XValues = .Range(.Cells(4, 1), .Cells(1000, 1))
ser.Values = .Range(.Cells(4, 2), .Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100
ser.Values = .Range(.Cells(4, 2 + k), .Cells(1000, 2 + k))
DoEvents 'allow Excel to catch up...
Next k
End With

End Sub





share|improve this answer


























  • @RachelSouthey if the answer was good for you, it is customary to accept it with the "tick" ...

    – Solar Mike
    Jan 3 at 7:55












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016328%2fcreating-a-code-to-read-multiple-sets-of-series-data-in-an-animated-graph%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














A ChartObject is just a "container" for a Chart, so you need something more like:



Worksheets("TR01db.vel").ChartObjects("Chart 1").Chart.SeriesCollection(1).XValues 'etc


A lot of repetition could be avoided by using some variables:



Sub Chart1()

Dim ws As WorkSheet, ser as Series
Application.ScreenUpdating = True

Set ws = ThisWorkbook.Worksheets("TR01db.vel")

With ws
.Activate
Set ser = .ChartObjects("Chart 1").Chart.SeriesCollection(1)
ser.XValues = .Range(.Cells(4, 1), .Cells(1000, 1))
ser.Values = .Range(.Cells(4, 2), .Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100
ser.Values = .Range(.Cells(4, 2 + k), .Cells(1000, 2 + k))
DoEvents 'allow Excel to catch up...
Next k
End With

End Sub





share|improve this answer


























  • @RachelSouthey if the answer was good for you, it is customary to accept it with the "tick" ...

    – Solar Mike
    Jan 3 at 7:55
















1














A ChartObject is just a "container" for a Chart, so you need something more like:



Worksheets("TR01db.vel").ChartObjects("Chart 1").Chart.SeriesCollection(1).XValues 'etc


A lot of repetition could be avoided by using some variables:



Sub Chart1()

Dim ws As WorkSheet, ser as Series
Application.ScreenUpdating = True

Set ws = ThisWorkbook.Worksheets("TR01db.vel")

With ws
.Activate
Set ser = .ChartObjects("Chart 1").Chart.SeriesCollection(1)
ser.XValues = .Range(.Cells(4, 1), .Cells(1000, 1))
ser.Values = .Range(.Cells(4, 2), .Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100
ser.Values = .Range(.Cells(4, 2 + k), .Cells(1000, 2 + k))
DoEvents 'allow Excel to catch up...
Next k
End With

End Sub





share|improve this answer


























  • @RachelSouthey if the answer was good for you, it is customary to accept it with the "tick" ...

    – Solar Mike
    Jan 3 at 7:55














1












1








1







A ChartObject is just a "container" for a Chart, so you need something more like:



Worksheets("TR01db.vel").ChartObjects("Chart 1").Chart.SeriesCollection(1).XValues 'etc


A lot of repetition could be avoided by using some variables:



Sub Chart1()

Dim ws As WorkSheet, ser as Series
Application.ScreenUpdating = True

Set ws = ThisWorkbook.Worksheets("TR01db.vel")

With ws
.Activate
Set ser = .ChartObjects("Chart 1").Chart.SeriesCollection(1)
ser.XValues = .Range(.Cells(4, 1), .Cells(1000, 1))
ser.Values = .Range(.Cells(4, 2), .Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100
ser.Values = .Range(.Cells(4, 2 + k), .Cells(1000, 2 + k))
DoEvents 'allow Excel to catch up...
Next k
End With

End Sub





share|improve this answer















A ChartObject is just a "container" for a Chart, so you need something more like:



Worksheets("TR01db.vel").ChartObjects("Chart 1").Chart.SeriesCollection(1).XValues 'etc


A lot of repetition could be avoided by using some variables:



Sub Chart1()

Dim ws As WorkSheet, ser as Series
Application.ScreenUpdating = True

Set ws = ThisWorkbook.Worksheets("TR01db.vel")

With ws
.Activate
Set ser = .ChartObjects("Chart 1").Chart.SeriesCollection(1)
ser.XValues = .Range(.Cells(4, 1), .Cells(1000, 1))
ser.Values = .Range(.Cells(4, 2), .Cells(1000, 2))
Application.ScreenUpdating = True

For k = 0 To 100
ser.Values = .Range(.Cells(4, 2 + k), .Cells(1000, 2 + k))
DoEvents 'allow Excel to catch up...
Next k
End With

End Sub






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 5:33

























answered Jan 3 at 5:24









Tim WilliamsTim Williams

89.3k97087




89.3k97087













  • @RachelSouthey if the answer was good for you, it is customary to accept it with the "tick" ...

    – Solar Mike
    Jan 3 at 7:55



















  • @RachelSouthey if the answer was good for you, it is customary to accept it with the "tick" ...

    – Solar Mike
    Jan 3 at 7:55

















@RachelSouthey if the answer was good for you, it is customary to accept it with the "tick" ...

– Solar Mike
Jan 3 at 7:55





@RachelSouthey if the answer was good for you, it is customary to accept it with the "tick" ...

– Solar Mike
Jan 3 at 7:55




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016328%2fcreating-a-code-to-read-multiple-sets-of-series-data-in-an-animated-graph%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith