From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example is written for an application in which needs to convert a number into its corresponding letter
Description
This example is written for an application in which needs to convert a number into its corresponding letter. For example, I need 1=A, 2=B, ..., 26=Z, 27=AA, ..., 52=ZZ, 53=AAA, etc. This example will return the corresponding letter for any positive integer number. This application may be useful when performing such tasks as referencing Microsoft Excel column names (A, B, C, ...) via ActiveX.
Requirements
Steps to Implement or Execute Code
Additional Information or References
Front panel
VI Snippet
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
27 gives AA which is correct, but 28 gives BB which is incorrect as the next column in excel is AB
You can design a quite simple VI working from A to ZZZ (which makes some 18928 rows) based on the indexing of an array containing an empty string and the 26 letters ! See the snippet attached for example !
Mine goes 0=A, 1=B,... 25=Z, 26=AA, 27=AB,... 701=ZZ, 702=AAA, etc... but you can make your own based on your needs !
I use it for Excel ActiveX in Labview, quite useful
Nicolas_Socomec wrote:
Mine goes 0=A, 1=B,... 25=Z, 26=AA, 27=AB,... 701=ZZ, 702=AAA, etc... but you can make your own based on your needs !
Found a bug in your code. 1377 is AZZ, but then 1378 is AZA (should be BAA). From there, you are off by 26.
Here is a more generic version (does not care how many letters it takes)
My bad, I had no use of so many columns so I did not test these values !
Thank you for your answer ! Maybe this post should be edited to mention your code or at least not refer to Excel column names ?