For each ui element get text and put in one cell only


I’m using for each excel row and then for each UI element activity.

I have one column in my excel for Names.


During for each UI element I store name as a variable.

I need to have all names in one cell.

But the problem is that if I do it this way, it shows: Mark, Mark

What do I do wrong?

Currently have:

Expected result:

Hi @anon40731888

You wanted to pass the three names into three rows of one column right?

If so, remove the last read and write cell activities.

No, into one cell.

This is how it goes:

  1. My automation goes for UI element #1 and get variable with a name: James
  2. My automation goes for UI element #2 and get variable with a name: Amy
  3. My automation goes for UI element #3 and get variable with a name: Mark

The problem is that I need all three names in one cell because sometimes there are 2 UI elements with 2 names, sometimes 5 UI elements with 5 names.

This is what I need because sometimes it might be:

Create variable finalNames as System.Collections.Generic.ICollection(of string) and in the Default put: New list(of string)

For Each UI Element

  • Get Text into currentName
  • Add to Collection, pass finalNames as collection, currentName as value
    //end For Each

Write Cell and put this into “What to write”: String.Join(", ",finalNames)

Thank you, I will try but it sounds very complicated.

This is a very simple, common type of operation requiring two variables and four activities.

Hi I know you are using StudioX I have one simple solution:
Make a String Type Variable resultString
Use one assign after get text activity

    • Assign activity: resultString = resultString + item.ToString() + ","

Put One Assign After Loop

  1. After the loop, remove the trailing comma from resultString using the TrimEnd method.
  • Assign activity: resultString = resultString.TrimEnd(","c)

Now Outside loop Write to Specific Cell with resultString


Then initialize one list variable then use append item to list activity to add the current item into list.(list type = System.Collections.Generic.List)

Then write into excel using for each.

Thank you, what do I type there? yellow?


This is for ui elements i simply put for each for reference.
Use for each ui element activity.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.