I want to trim a cell’s input to 25 characters, and if there’s a space at the 25th position, cut it off. If there isn’t a space, find the nearest space, move frontward, and cut it off. The remaining characters should then move to the next row, and the process repeats. If the last row has characters that are less than or equal to 25, the robot should end.
I’ve tried using length, trim, and replace, but it didn’t work. Is there a way to achieve this?
The question is insufficient, so I explain it in an image.
Thank you in advance for your response!
@ppr
I appreciate your response. It seems to be a solution to a similar problem. However, since I am at the stage of learning UiPath, I don’t quite understand it well. Could you provide more details about the flow you have in mind regarding my question?
Please find the solution attached. I have taken the example on the screenshot and wrote it from A3 incrementing the cell count. You can do string manipulation according to your requirement and modify the solution.
Write Cell: The length of the string cannot be zero.
Parameter Name: oldValue
I appreciate your response. HOWEVER I encountered an error while applying the code. The text I’m working with is ’ SKSKSKS Business Solution Corp. 2500 OKAKSA MijimashiraRRRRRR city, hajagawAAa USA 2500 Tel: Fax:', and I’m wondering if you could provide a solution for this issue.
@ppr
Thank you for the response. Could you please share your code with me as a file? I’m experiencing an error in the regex, so I would appreciate your assistance.
@pravallikapaluri
Thank you for your response! I think the error was my mistake.I was amazed by your answer. Could you please guide me on how to save the last output to each cell in an Excel file?
Use a for loop on System.Text.RegularExpressions.Regex.Matches(inputString, ".{1,25}(\s|$)")
Inside loop use write cell and use auto increment checked on it…and gice the cell value as Excel.Sheet("SheetName").Cell("A1") and then value as currentitem.Value