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 / Need a help in Copy an...
Power Automate
Unanswered

Need a help in Copy and Paste issue in Power automate desktop in Excel

(0) ShareShare
ReportReport
Posted on by 203

Hi Everyone,

 

I need to copy data from a pivot table and paste it into an Excel sheet where permanent headers are present. The challenge is that the pivot table may not always have the same headers. For example, in the snapshot below, the table has four headers: Apple, Ball, Cat, and Dog. However, sometimes the pivot table may not include the "Cat" header. In such cases, I need to copy and paste the data while leaving the "Cat" column empty. How can I achieve this in powerautomate desktop flow ?

 

Ahmedmuz_0-1697529282668.png

 

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Ahmedmuz 

    It is possible.

     

    Sharing a demo flow with steps to get an idea on how to design such flows 🙂

     

    So i have created a excel file , it has three sheets : Sheet1 , Sheet2, Sheet3 (Sheet3 we won't discuss).

     

    Nived_Nambiar_0-1697561120000.png

     

    Nived_Nambiar_1-1697561128320.png

     

    Sheet2 has Pivot table (datasource is from Sheet3)

     

    Now go to flow 

     

     

    Step1: Launch the excel file by passing the file path 

    Nived_Nambiar_2-1697561204522.png

     

     

    Step2: Make sheet2 (which has pivot table) as active 

    Nived_Nambiar_3-1697561304379.png

     

    Step3: Get the first free row/column from active worksheet (i.e Sheet2)  and for easy reference, i have named both variables (first free row and first free column) as PivotFreeRow and PivotFreeColumn respectively.

     

    Step4: Read the data from active worksheet by passing data from previous step and store in a datatable variable, let's say PivotData

    Nived_Nambiar_4-1697561433003.png

     

    Step5: Now set active worksheet as Sheet1 (which is the table we are writing the data from pivot table)

    Nived_Nambiar_5-1697561504624.png

     

    Step 6:Read the data from active worksheet (i.e Sheet1) like below

    Nived_Nambiar_7-1697561608240.png

     

    Note: here i am reading data from A1 to D1 , only for the headers data, in my case my headers in Sheet1 are upto D1, so provided like that you can change the D to required column letter to which your column is present in the worksheet where you need to write the data.

     

    Step7: Create a new datatable variable named %dt1Final% with value like below

    Nived_Nambiar_8-1697561746050.png

     

    this will create a dattable with headers only of that of Sheet1.

     

    Step 8: Create a new list let's say %rowitem% (this would be for temporary data storage)

    Nived_Nambiar_9-1697561847690.png

     

    Step 9: iterate through each row of PivotData datatable using for each action

    Nived_Nambiar_10-1697561884323.png

     

    Let's discuss what happen inside the loop in sub steps 

     

    Step 9.1: Clear the rowitem list

    Nived_Nambiar_11-1697561925399.png

     

    Step 9.2: Now loop through each col in %ExcelData.Columns% like below

    Nived_Nambiar_12-1697561971741.png

     

     Step 9.2.1: check %PivotData.Columns% contains %col% value in it, if 

     

      value Present: then add %row[col]% to %rowitem% list

     value not present: then add %''% to %rowitem% list 

     

    Step 9.3 : append the rowitem to dtFinal like below

    Nived_Nambiar_13-1697562159834.png

     

    Step 10: use write to excel to write the dtFinal to excel file like below 

    Nived_Nambiar_14-1697562193658.png

     

    Step 11: close the excel

    Nived_Nambiar_15-1697562211475.png

     

    So overall flow looks like this:

    Nived_Nambiar_16-1697562251587.png

     

    Nived_Nambiar_17-1697562264756.png

     

     

    Hope this design helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

     

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 259 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 227 Super User 2026 Season 2

#3
Valantis Profile Picture

Valantis 134 Super User 2026 Season 2

Last 30 days Overall leaderboard