Separate String on newlines in Excel

If you press ALT + Enter on excel you can write in the same cell but on a different line.

I want to know how I can separate each new line and save it as it’s own string.

Hi,

You can get whole data of the cell by Read Cell Activity.

Then, you can get each line as array of string using split method like the following.

arrStr = strWholeCellData.split(vbLf)

Regards,

2 Likes

is this the input?

I did IGusername.split(vbLf) and am getting the error option strict on disallows implicit conversions from ‘String’ to ‘Char’

Hi
try to convert vbLF to char type using cType or similar

vbLF is a constant

Not sure what you mean.

I am using read cell activity to give me the data in the cell and I store it in the variable called username.
Let’s say username becomes:
“sami
syed”

Now I want to split this string by and store sami, and syed in a sperate varaible. How can I do this?

your problem is clear

try strWholeCellData.split(CType(vbLF, Char))

2 Likes

I would suggest to think over case when names are separated by other symbols such as space or tab or comma for example could your algorithm work in this case ?

Now I am getting this error:

Value of 1-dimensional array of string cannot be converted to string

Nvm I converted it to variable array of string and it worked.

correct