LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the easiest way to always increment to index 0 only for a multi-element array ?

Solved!
Go to solution

The premise is to populate a spreadsheet from left to right in the same row but incrementing the column letter only (ie - B4, then C4 etc). Attached I have customized an existing example VI that works for a 2 element array (ie - B4) but does not work for a 3 element array (ie - B40, then becomes B50). Keeping it simple, what is the best and easiest way to modify my existing code to always check the array size and automatically index back to 0 in order to properly increment the first letter only (ie - B) and not the number (ie - 4) ?

 

Thanks !

 

Barry

  

0 Kudos
Message 1 of 5
(2,981 Views)
Solution
Accepted by topic author biernaskieb

Instead of "automatically index back to zero" , why not just make it a zero instead of doing the array size -1-1 manipulations?

 

Of course this will all fall apart once you get to column Z.

 

Also look into the Excel Board.   Don't post question there.  It is just a link to other threads related to Excel.  Some of them might give you better ideas how to manipulate your cell references.

0 Kudos
Message 2 of 5
(2,973 Views)

Yup it works ! I modified the code as suggested (initializing index to always be 0 with a 0 constant). I tried various numbers of elements in the array and they all work !

 

Thanks for the suggestion !

 

Barry

 

0 Kudos
Message 3 of 5
(2,962 Views)

In case you ever have more than 26 columns (as Ravens Fan noted), here is some code I use to generate the column label from the column number (0=A,1=B,...).

 

 

0 Kudos
Message 4 of 5
(2,947 Views)

Thanks for the code suggestion ! This will definitely come in handy for those Mega Data Spreadsheets that require data collection automation using LabVIEW !

 

Thanks again !

 

Barry

 

0 Kudos
Message 5 of 5
(2,927 Views)