LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert new cell into Excel WorkSheet

Solved!
Go to solution

Hi guys,

 

I need to insert a new cell into a specific worksheet. My application runs only for one worksheet(see sample.xls),if I have more worksheet(see sample1.xls) it doesn't work.If you have an idea it will be great.

 

Thanks to all, Samoth

0 Kudos
Message 1 of 12
(3,632 Views)

So do you need to open all XLS files in some folder and insert this cell?

Tim
GHSP
0 Kudos
Message 2 of 12
(3,625 Views)

sample1.xls does not have a tab called sample. so when it opens the xls file it never finds the wooksheet that you are trying to add a cell to. I need to know more information to be able to help you figure out what you need.

Tim
GHSP
0 Kudos
Message 3 of 12
(3,618 Views)

 


@aeastet wrote:

sample1.xls does not have a tab called sample.


Indeed. Can't access a sheet that doesn't exist. And, the error you get tells you the answer: the description says "Invalid index." Did you run the code in highlight mode? You would have seen the "Sheets -> Item" method generating that error.

 

0 Kudos
Message 4 of 12
(3,608 Views)

Hi all,

 

Even changing the sheet name(as, sheet1, sheet2) does not solve the problem all the time. When i remove the method called "Select" used after the cell position setting, I found its working fine for all the sheets.

 

Any Idea?

0 Kudos
Message 5 of 12
(3,587 Views)

No, in sample1.xls try with one of its worksheet (Sheet1, Sheet2 or Sheet3), not with WSheet sample.

I' ve started with workbook sample.xls , if you run the VI , as you can see I can insert a new cell . I wish to do the same in case of sample1.xls choosing one of its worksheet.

 

Thanks, Samoth

0 Kudos
Message 6 of 12
(3,577 Views)

No, in sample1.xls try with one of its worksheet (Sheet1, Sheet2 or Sheet3), not with WSheet sample.

I' ve started with workbook sample.xls , if you run the VI , as you can see I can insert a new cell . I wish to do the same in case of sample1.xls choosing one of its worksheet.

 

Thanks, Samoth

0 Kudos
Message 7 of 12
(3,576 Views)

Exactly

0 Kudos
Message 8 of 12
(3,574 Views)

After a quick play with this, I think there seems to be some problem with the way you select the worksheet you wish to use.

If I save the spreadsheet with Sheet3 at the front, I can then insert cells into Sheet 3, but not into Sheet1 or Sheet2.

If I save the spreadsheet with Sheet1 at the front I can insert cells into Sheet1 etc...

 

Looking here there is some advice on how to do what you are trying to but it looks to me as though this is what you've done.

 

Maybe have a play with different ways of indexing your worksheet and see if that helps.

0 Kudos
Message 9 of 12
(3,548 Views)

Thanks _Ian_, I solved the problem.

 

Have a nice day, Samoth

0 Kudos
Message 10 of 12
(3,541 Views)