Extract numbers only from Excel column


I have the excel as shown below and I need to remove the front Characters and the space in between and keep only the numbers and put the whole in a new column in a new excel sheet. Here’s the excel file.
Can you help please?


UIPath_Excel_Scratch (2).xlsx (6.8 KB)

Hi @Yudhisteer_Chintaram1

Try like this

  1. Add a column named **Modified Product ID ** in the excel

  2. then use read range to read the excel file and store in dt1

3.Next use invoke code activitiy with dt1 as In/Out argument

Use below code in that activitiy

dt1.AsEnumerable().ToList().ForEach(Sub(row) row(“Modified Product ID”)= System.Text.RegularExpressions.Regex.Match(row(“Product ID”).ToString, “[^A-Za-z]”).Value.ToString)

Then after invoke code, use write range activitiy to write the updated dt1

Hope it helps you


Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

1 Like

Hi @Yudhisteer_Chintaram1 ,

An alternative to invoke code would be this simple workflow:

System.Text.RegularExpressions.Regex.Replace(row.item(2).ToString, “[a-zA-Z]”, “”).Trim

More about regex you can find here: https://forum.uipath.com/t/regex-help-tutorial-megapost-making-your-first-regex-post-reusable-regex-patterns-regex-troubleshooting-sample-workflow-and-more/238791

Demo file: ExtractDigits.xaml (6.2 KB)

Best regards,


It worked but with an excel sheet of about 30 columns, I get this error:

Assign: Exception has been thrown by the target of an invocation.


you are missing to add data column or you are passing the wrong column index to the assign row.item()


If there is an option to change the solution, Please mark @Marius_Puscasu as the Solution…
I just highlighted the issue…

1 Like

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