web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to replace bits of...
Power Automate
Answered

How to replace bits of a string that contains new lines?

(0) ShareShare
ReportReport
Posted on by 18

Hi there!
I have a string that's coming from a cell in excel that contains multiple lines like so:


Line 1 what the beep?

Line 2 beep boop bap.

Line 3 hello beep.


How do I replace all instances of 'beep' with 'hello'?

I've tried everything I can think of and no luck so far 😞 The normal replace function doesn't seem to do it, and my javascript attempts don't even return anything?

function ExecuteScript() { 
 var res = %ExcelCellContents%.replace("WORKBOOKS", "red");
 WScript.echo(res);
}

 

I have the same question (0)
  • Verified answer
    VJR Profile Picture
    7,635 on at

    Hi @Gilariel1 

     

    If you want to replace the text directly in Excel then you can use Find and replace cells in Excel worksheet action.

     

    But if you want a string function then the Replace Text works perfectly fine.

     

    After running the process, the replaced words are as highlighted below.

     

    VJR_0-1668307805776.png

     

  • Gilariel1 Profile Picture
    18 on at

    Thanks for the response VJR.
    Yes if I just use a string variable like you did then it works, but if I pull that from the excel cell (like I need to do) it doesn't work for some reason? Any ideas?

    Last time I tried the excel find and replace it also didn't work with newlines in cells unfortunately. But maybe this has changed in 2022?

     

  • VJR Profile Picture
    7,635 on at

    Make sure to disable entire cell contents.

     

    VJR_1-1668329416704.png

     

     

  • Gilariel1 Profile Picture
    18 on at

    Thanks, this was very helpful.
    I got this to work with individual words and very short phrases, but not with paragraphs. I think maybe there's a max limit to how much text you can replace at once (this seems to be the case even in Excel's native find and replace too from what I can see!), so I think that's where I was going wrong too.

    Thanks so much for your help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 241 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 179

#3
Haque Profile Picture

Haque 159

Last 30 days Overall leaderboard