LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to add more chart sheets in excel

I am working on a VI for data analysis. I have data coming from a spreadsheet file, and I used the excel macro example.vi and I was able to produce a single chart(with column 1 as X-axis and column 2 as Y axis). But I have eight columns of data and I want create eight different chart (like next chart would be column 1 as X-axis and column 3 as Y-axis) and each in a seperate sheet. I tried to modify the macro but I am getting error in Set cell range.vi. Do I have to add sheets after opening the excel book in Macro excel.vi. Any help is appreciated.
0 Kudos
Message 1 of 3
(2,874 Views)
I would suggest starting with the Write Table to XL example, or staying with the current example, and seeing if you can get all the data to the sheet. If this part fails what error are you getting? Does it work with 1 column?

Once you are able to get all the data on a sheet, without worrying about how to chart it you are basically done. If you open the Excel sheet that the macro example uses and take a look at the Macro code, All you have to do is put a for loop around the whole set of code and run the loop 8 times.
0 Kudos
Message 2 of 3
(2,874 Views)
You state that you modified the macro and are getting an error in the Set Cell Range.vi. This tells me that you ran the Macro Example.vi, then modified the macro, then saved your Excel workbook. What you have now is a workbook with two sheets. The first sheet is the sample chart, and the second is the worksheet with the sample data.

The problem is that Excel remembers that the chart was the last sheet used and re-opens with that sheet active. The Macro Example.vi selects the sheet by Sheets(1), not WorkSheets(1) or Sheets("Sheet1"), and therefore is trying to write your data to the chart. If you delete the chart sheet, you should be able to modify the macro to create 8 new charts without adding any sheets.

Michael
www.abcdefirm.com
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 3 of 3
(2,874 Views)