user1270123
user1270123

Reputation: 573

Populating multiple graphs in Excel VBA

I have an Excel macro that populates a graph from .csv files, with values starting from cells A1, B1 in x and y axes. Now when I add multiple .csv files with values ranging from A3, B3, it throws an error saying the cells are empty. Any idea why this happens?

Upvotes: 1

Views: 424

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149277

Change the lines

Plot_y = Range("C1", Selection.End(xlDown)).Rows.Count
Plot_x = Range("D1", Selection.End(xlDown)).Rows.Count

to

Plot_y = Range("C" & Rows.Count).End(xlUp).Row
Plot_x = Range("D" & Rows.Count).End(xlUp).Row

And try again.

Upvotes: 2

Related Questions