# How to split excel value string

**URL:** <https://forum.uipath.com/t/how-to-split-excel-value-string/385070>\
**Category:** Activities\
**Tags:** question, excel, system, activities\
**Created:** [December 24, 2021, 11:14am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070 "2021-12-24T11:14:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learner007](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/learner007/32/276338_2.png) [@Learner007](https://forum.uipath.com/u/Learner007)\
**Post date:** [December 24, 2021, 11:14am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/1 "2021-12-24T11:14:10Z")

</div>

Hi All, i struct in splitting a string can anyone suggest me how to split a string.

Input EX: 1) CNP-46TAC9 2020-01-POC-RC6  
2) 2021-KC-MNC-Pro

Output: CNP  
46TAC9  
2020  
01  
POC  
RC6

Output 2: 2021  
KC  
MNC  
Pro

---

<div class="post-metadata">

**Author:** ![pravin\_calvin](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pravin_calvin/32/212149_2.png) [@pravin\_calvin](https://forum.uipath.com/u/pravin_calvin)\
**Post date:** [December 24, 2021, 11:22am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/2 "2021-12-24T11:22:25Z")

</div>

Hi @Learner007

Use the below expression to split!

**InputString.Split("-"c)**

And Use For each to iterate the string values

Regards

---

<div class="post-metadata">

**Author:** ![kirankumar.mahanthi1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kirankumar.mahanthi1/32/322620_2.png) [@kirankumar.mahanthi1](https://forum.uipath.com/u/kirankumar.mahanthi1)\
**Post date:** [December 24, 2021, 11:28am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/3 "2021-12-24T11:28:49Z")

</div>

Hi @Learner007 ,

Since we are getting different combinations first we have to replace the blank space with the keyword - like below.

Yourstring.replace(" “,”-")

Now please follow the suggestion by @pravin_calvin .

Yourstring.split("-“c)(0) → to get the first one.  
Yourstring.split(”-"c)(1) → to get the second one so on.

or you could use string arry to capture all the entries like below.

strarr = Yourstring.split("-"c)

and use for each loop to get all the splitted strings one by one. thanks.

---

<div class="post-metadata">

**Author:** ![Hiba\_B](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hiba_b/32/524496_2.png) [@Hiba\_B](https://forum.uipath.com/u/Hiba_B)\
**Post date:** [December 24, 2021, 11:31am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/4 "2021-12-24T11:31:11Z")

</div>

Hi @Learner007 !  
Welcome to UiPath Community 😄

Here is a suggestion: [Split data.xaml](https://forum.uipath.com/uploads/short-url/9YJjqQeTFBoWAd4o0xETGzkOk7r.xaml) (8.0 KB)

---

<div class="post-metadata">

**Author:** ![Learner007](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/learner007/32/276338_2.png) [@Learner007](https://forum.uipath.com/u/Learner007)\
**Post date:** [December 24, 2021, 11:34am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/5 "2021-12-24T11:34:06Z")

</div>

Hi @kirankumar.mahanthi1 some time i’m getting 2 or 3 spaces is there any way to replace at a time or i need to replace activity multiple times

---

<div class="post-metadata">

**Author:** ![pravupada](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pravupada/32/415171_2.png) [@pravupada](https://forum.uipath.com/u/pravupada)\
**Post date:** [December 24, 2021, 11:38am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/6 "2021-12-24T11:38:09Z")

</div>

try this:  
yourString.Split(New String(){" “,”-"},StringSplitOptions.None)

Thanks  
pravu.

---

<div class="post-metadata">

**Author:** ![kirankumar.mahanthi1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kirankumar.mahanthi1/32/322620_2.png) [@kirankumar.mahanthi1](https://forum.uipath.com/u/kirankumar.mahanthi1)\
**Post date:** [December 24, 2021, 11:39am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/7 "2021-12-24T11:39:58Z")

</div>

Replace activity replace all the blank spaces to key word at a time. No need to use multiple times or use some valuable suggestion given by the other members in this thread. Thanks.

---

<div class="post-metadata">

**Author:** ![Jobin\_Joy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jobin_joy/32/555040_2.png) [@Jobin\_Joy](https://forum.uipath.com/u/Jobin_Joy)\
**Post date:** [December 24, 2021, 1:10pm UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/9 "2021-12-24T13:10:45Z")

</div>

Hi @Learner007

Can you please try the below code?

 ![image](https://global.discourse-cdn.com/uipath/original/4X/9/0/7/90709ac5d4742224599da81bf4f2e7097804e865.png)

**Code:**  
[Main.xaml](https://forum.uipath.com/uploads/short-url/5A5ZiQ5QJPiLgSivbnDJISieumF.xaml) (6.4 KB)

Thank you.

---

<div class="post-metadata">

**Author:** ![Learner007](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/learner007/32/276338_2.png) [@Learner007](https://forum.uipath.com/u/Learner007)\
**Post date:** [December 27, 2021, 4:18am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/10 "2021-12-27T04:18:23Z")

</div>

hi @Jobin_Joy this is working for single space , some times i will get 2 or 3 spaces in between i want to replace them by (-) how can i replace multiple spaces into single value (-)

---

<div class="post-metadata">

**Author:** ![Jobin\_Joy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jobin_joy/32/555040_2.png) [@Jobin\_Joy](https://forum.uipath.com/u/Jobin_Joy)\
**Post date:** [December 27, 2021, 4:31am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/11 "2021-12-27T04:31:56Z")

</div>

Hi @Learner007

Please use the below code for your requirement.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/b/f/7/bf77409aaf877103b482e3db702d3a2add947505.png)

**Updated Code:**  
[Main (1).xaml](https://forum.uipath.com/uploads/short-url/zLxaaVJF7a1lNJvFm1DL49j0zwm.xaml) (7.2 KB)

Hope this will be helpful. Thank you.

---

<div class="post-metadata">

**Author:** ![Learner007](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/learner007/32/276338_2.png) [@Learner007](https://forum.uipath.com/u/Learner007)\
**Post date:** [December 27, 2021, 4:41am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/12 "2021-12-27T04:41:10Z")

</div>

Thanks @Jobin_Joy it’s working

---

<div class="post-metadata">

**Author:** ![Jobin\_Joy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jobin_joy/32/555040_2.png) [@Jobin\_Joy](https://forum.uipath.com/u/Jobin_Joy)\
**Post date:** [December 27, 2021, 4:42am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/13 "2021-12-27T04:42:32Z")

</div>

Glad to hear that it’s helped you. Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [December 30, 2021, 4:43am UTC](https://forum.uipath.com/t/how-to-split-excel-value-string/385070/14 "2021-12-30T04:43:28Z")

</div>

Closed on December 30, 2021, 4:43am UTC

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