cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
barney1234
Regular Visitor

how to get file name and compare it to excel sheet name

hi everybody. i am really new to this world. i want to create a flow that when i add a file name to a folder.

it will get the file name, compare the file name to an excel worksheet and check if they match. if they don't, it I will create a new excel sheet by the file name.

1 ACCEPTED SOLUTION

Accepted Solutions
eric-cheng
Solution Sage
Solution Sage

Hi @barney1234 ,

 

Try the below flow.

 

1) Use a when a file is created in a folder trigger and then get metadata

 

ericcheng_0-1627908798964.png

2) Initialize a Boolean variable and set it to @false.  Add a Get worksheets action to get all the worksheets in your Excel

ericcheng_1-1627908884215.png

3) Loop through each Excel worksheet and add a condition where Name of worksheet is equal to Name of file (from Get File Metadata).  If found, set Boolean variable to @true

ericcheng_2-1627908980115.png

 

 

 

 

4) Exit the loop.  Add another condition to check whether your Boolean is false (i.e. it did not find a worksheet with the same name).  If true, create a worksheet with the name of the file (from Get File Metadata).

ericcheng_3-1627909076982.png

ericcheng_4-1627909101467.png

 

 

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

 

 

 

View solution in original post

1 REPLY 1
eric-cheng
Solution Sage
Solution Sage

Hi @barney1234 ,

 

Try the below flow.

 

1) Use a when a file is created in a folder trigger and then get metadata

 

ericcheng_0-1627908798964.png

2) Initialize a Boolean variable and set it to @false.  Add a Get worksheets action to get all the worksheets in your Excel

ericcheng_1-1627908884215.png

3) Loop through each Excel worksheet and add a condition where Name of worksheet is equal to Name of file (from Get File Metadata).  If found, set Boolean variable to @true

ericcheng_2-1627908980115.png

 

 

 

 

4) Exit the loop.  Add another condition to check whether your Boolean is false (i.e. it did not find a worksheet with the same name).  If true, create a worksheet with the name of the file (from Get File Metadata).

ericcheng_3-1627909076982.png

ericcheng_4-1627909101467.png

 

 

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

 

 

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,137)