Skip to main content

Notifications

Community site session details

Community site session details

Session Id : ZveTiS8te/qRNdd22LrYso
Power Automate - Power Automate Desktop
Unanswered

Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

Like (0) ShareShare
ReportReport
Posted on 7 Sep 2021 08:11:19 by 111

Hello  

I have a problem with the new  Find and replace cells in Excel Worksheet" action.

 

I am using it to find a word, it works brilliantly when you find a word that exists but when it fails to find I expect it to let me know and not carry on as nothing happened.  Below is a screenshot of a very basic flow where we look for a word potato that does not exist in the file. As it isn't finding it should go to a label and set a variable but it is not doing any of these and just carries on without either logging a fault or performing the actions on not fund.

 

Does anyone else experience this?  

 

DanielOlsson_0-1631002073442.png

 

  • VJR Profile Picture
    7,635 on 08 Sep 2021 at 09:34:19
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Hi @DanielOlsson ,

     

    I understood what you are trying to convey and so tried the same.

     

    When 'All' is selected and if there are no matches found, then the Rows will always show 0.

    Meaning: the Cells Datatable has 0 Rows in the below case.

    VJR_0-1631093473698.png

     

    If something is found then Rows will have a non-zero value.

    Meaning: the Cells Datatable has 1 Row in the below case.

    VJR_1-1631093526505.png

     

    So checking the value of Rows will suffice.

     

    Rows value of Cells Datatable: %Cells.RowsCount%

     

    After displaying the above message:

    VJR_0-1631094361624.png

     

     

     

  • sunilb Profile Picture
    Microsoft Employee on 08 Sep 2021 at 08:52:06
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Above action will through error only when it has problem in finding and/or replacing the specified text. 

    Kindly refer the below article. https://docs.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/excel#findandreplaceaction_onerror

     

    We need to go with the solution which is mentioned by @VJR 

     

     

  • DanielOlsson Profile Picture
    111 on 08 Sep 2021 at 08:25:08
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Hello VJR, that is actually a good workaround as locations remain 0 0 as it does not find. A simple IF statement checking the output. 

     

    But if we look for "all", the variable produced changes to %Cells% and that remains totally empty with no zero. As well a workaround but if in a loop, there is no way to clean a variable to be empty and it will contain old values as it does the 2nd search?

  • VJR Profile Picture
    7,635 on 08 Sep 2021 at 04:24:54
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Hello @DanielOlsson ,

     

    You could think of taking the next desired course of action based on the FoundColumnIndex and FoundRowIndex output variables.

     

    If not found, both return 0.

     

    VJR_0-1631074920840.png

     

    When text is found returns non-zero values.

    VJR_1-1631075035784.png

     

     

  • DanielOlsson Profile Picture
    111 on 07 Sep 2021 at 19:20:34
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Update to the latest version. it was in Aug release. 

  • MichaelAnnis Profile Picture
    5,721 Super User 2025 Season 1 on 07 Sep 2021 at 16:51:24
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Is this a Beta action? I can't seem to find it...

    MichaelAnnis_0-1631033474340.png

     

  • MichaelAnnis Profile Picture
    5,721 Super User 2025 Season 1 on 07 Sep 2021 at 10:52:29
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Agreed.  However, my gut is telling me that the text not existing in “find and replace” is not an error, so you won’t be able to get there with the error module.  

    I can toy around with it in about 3 hours and see if there is a better solution, but I am suspecting that to say “if text does not contain ‘potato’, change to Not Found” will have to be done another way.

  • DanielOlsson Profile Picture
    111 on 07 Sep 2021 at 10:34:39
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Hello Everyone


    Support just called me and they have agreed that there is a potential defect in the response from this new action. When the action do not find what its asked to look for, it should execute the instruction set and it does not hence its been forwarded back to developers. In case you have the same experience.

     

    Regards

    Daniel

  • DanielOlsson Profile Picture
    111 on 07 Sep 2021 at 10:32:42
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    Hello Michael 

    The whole point of this action is to avoid making lookup loops, it's a new feature in the latest release.

  • MichaelAnnis Profile Picture
    5,721 Super User 2025 Season 1 on 07 Sep 2021 at 10:13:20
    Re: Excel "Find and replace cells in Excel Worksheet" action is NOT working when it can not find text

    I haven’t used this feature, so I am just going to say what I think is happening and how to work around that. 

    The error “failed to find and replace text” does not mean the text didn’t exist. I believe it means that the process literally failed (ex. Your Excel Instance was closed).  

    So, I would rewrite this to:

    Read from Excel (Range) to %ExcelData%

    For each %CurrentItem% in %ExcelData%
         If %CurrentItem% does not contain “potato”

            Change %CurrentItem% to “Not found”

        Else

            Replace text “potato” with “whatever”

        End If

    End

    Write %ExcelData% to (Range)

     

    This extracts it all into a DataTable, rewrites it in the DataTable, then writes the DataTable back to Excel. 

    Best of luck!

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Power Automate Desktop

#1
eetuRobo Profile Picture

eetuRobo 18 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 6

#2
John_Mavridis Profile Picture

John_Mavridis 6 Microsoft Employee

Overall leaderboard
Loading started