Hi everyone
I’m trying to find a column location by its name
For example, I want to find the index of the column by the name “Name”.
there is a lookup activity, but I learned that it’s not that accurate…
I tried “Convert.ToChar(65+DT.columns.IndexOf(“Date”))” and for some reason it gave me ‘@’.
thank you all for the help
Hello and good morning,
If you are trying to find the index of a column by using its name, this forum post may help you
The -1 I get (this is normally what happens)
but why the ‘@’??? and how do I fix this?
@dlichtenstadt Are you using this to get the Range name ? Like “A” or “B”
You get @ Symbol when the DT.columns.IndexOf(“Date”) is -1
it didn’t helped me this post
Ohh so instead of getting ‘-1’ I’m getting ‘@’ (good to know)
BUT the column name that I’m searching for is exist and it still gives me this problem…
@dlichtenstadt We would have to see the Excel Data for that and make sure that you have used Add Headers in Read Range when you’re reading the Excel File
Yeah I’m searching for the index because later on, I need to write to this column and I’m using the activity “write cell” with index and counter (or the row from a ‘for each row’ I have at the beginning)
@dlichtenstadt Have you tried to Check with a different Column Name if you’re able to get it’s Range Name ?
I changed the reading range - from 2 rows to the whole DT and it worked
don’t know why it mattered because I told him to read with headers and to read 2 rows, so it’s supposed to be working well.
after I took down the range and gave it the full DT it worked (Convert.ToChar(65+DT.columns.IndexOf(“columnNmae”)))
I want to ask another Question
I need to write into a cell a data that I got from the process.
I’m using “write cell” inside an “excel scope”, but my problem is that I want to write in the correct row (all this is inside a “for each row”) so I have my Index (A, B, C) and now I want to add the row so it will write the correct value in the correct row (each row have different values)
thank u all again
@
is the result of Convert.ToChar(65 - 1)
: you’re adding -1
(the not found index) to 65