Hello, I have managed to get the column number e.g. 4 and I want to change this into “D” so that I can use this to write stuff in to Excel.
Any help?
Hello, I have managed to get the column number e.g. 4 and I want to change this into “D” so that I can use this to write stuff in to Excel.
Any help?
please explain with a scenario, what you have stated here is too vague for us to understand what you are asking.
Sorry guys, for example, I have got the column number/index in a datatable (4). I have also got the row number e.g. 4. In VBA, I would write this as (4,4) but UiPath does not allow me to do this as I would need to write it as (D4). Therefore, is there a way to convert the integer 4 to the corresponding alphabet/Excel letter (D)
Sorry for any confusion!
Hi @mzucker
Actually i dont get the issue but if you want to transform the 4 to D just use simple case is fine.
cheers
Happy learning
what is simple case?
Hello @mzucker
use this code
Convert.ToChar(Convert.ToUInt16("@"c)+4)
you can also start with A but then to get D you’ll have to add 3
Convert.ToChar(Convert.ToUInt16("A"c)+3)
Use what suits you the best !!!
As @DanielMitchell said below the above could work for 26 letters.You could always get two letter by using an IF condition and assigning the above code twice with a + sign like this
Convert.ToChar(Convert.ToUInt16("A"c)+3)
+Convert.ToChar(Convert.ToUInt16("A"c)+3)
So If the digits are higher then I would suggest you to use @DanielMitchell link i tried the logic and methods used in that link and it works flawlessly.
Check the workflow below it contains logic used in that link
ColumnLetterFor.xaml (7.3 KB)
The formula at the link above should help you. This will work for any number of columns, including higher than 26 where excel has “AA” and so on.
Hello, here is the code that converts any index to a column name ChangeColumnNoToName.xaml (11.6 KB)
Hi,
Converting the Excel Column type . you can use the “ChangeCellType”. Which is existing in the below link.
Regards
Balamurugan.S
You can directly use this XAML. Hope it helps.
ExcelGetColumnNumberFromLetter.xaml (6.0 KB)