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?
-
Can you share the code that you are using?Siddharth Rout– Siddharth Rout2012-05-10 16:34:10 +00:00Commented May 10, 2012 at 16:34
-
2shared.com/file/Y-zly51v/macro_test.htmluser1270123– user12701232012-05-10 16:44:22 +00:00Commented May 10, 2012 at 16:44
-
The following folder has a macro file and two .csv files, the macro works if one of the files is deleted..user1270123– user12701232012-05-10 16:45:15 +00:00Commented May 10, 2012 at 16:45
-
Which line is giving you the error? I got an error on a different line which was expected but I am not getting the error that you have mentioned above.Siddharth Rout– Siddharth Rout2012-05-10 16:54:56 +00:00Commented May 10, 2012 at 16:54
-
this line Plot_y = .Range("B1",Selection.End(xlDown)).Rows.Countuser1270123– user12701232012-05-10 17:08:28 +00:00Commented May 10, 2012 at 17:08
|
Show 1 more comment
1 Answer
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.
2 Comments
user1270123
I get an error called "invalid or unqualified reference" after making this change in the very same lines
Siddharth Rout
sorry my mistake, I had directly typed it here. Remove the dots before
.Rows updating my post above