Reputation: 573
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
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