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 / power automate desktop...
Power Automate
Unanswered

power automate desktop copy and paste excel with the same formatting

(2) ShareShare
ReportReport
Posted on by

I have a question, that is how to copy an excel sheet and paste in a new created worksheet with the same formatting?

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @Tracy1 ,

     

    You can achive this by using Run Vbscript action.The Vbscript to do the above scenario is provided below. Please change the paths of the file.

    Dim objExcel, objWorkbookInput, objWorkbookOutput
    Dim objWorksheetInput, objWorksheetOutput
    Dim inputFilePath, outputFilePath
    Dim newSheetName
    
    ' Define the paths to the input and output Excel files
    inputFilePath = "input.xlsx"
    outputFilePath = "output.xlsx"
    newSheetName = "CopiedSheet" ' Name of the new sheet to be created
    
    ' Create an instance of Excel
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = False ' Set to True if you want to see the process
    
    ' Open the input Excel workbook
    Set objWorkbookInput = objExcel.Workbooks.Open(inputFilePath)
    
    ' Open the output Excel workbook
    Set objWorkbookOutput = objExcel.Workbooks.Open(outputFilePath)
    
    ' Assume data is on the first sheet of the input workbook
    Set objWorksheetInput = objWorkbookInput.Sheets(1)
    
    ' Add a new worksheet to the output workbook
    Set objWorksheetOutput = objWorkbookOutput.Sheets.Add
    objWorksheetOutput.Name = newSheetName
    
    ' Copy all data from the input worksheet
    objWorksheetInput.UsedRange.Copy
    
    ' Paste the data into the new worksheet in the output workbook
    objWorksheetOutput.Range("A1").PasteSpecial -4163 ' -4163 corresponds to xlPasteAll
    
    ' Save and close the output workbook
    objWorkbookOutput.Save
    objWorkbookOutput.Close
    
    ' Close the input workbook without saving
    objWorkbookInput.Close False
    
    ' Quit Excel
    objExcel.Quit
    
    ' Clean up
    Set objWorksheetInput = Nothing
    Set objWorksheetOutput = Nothing
    Set objWorkbookInput = Nothing
    Set objWorkbookOutput = Nothing
    Set objExcel = Nothing
    
    MsgBox "Sheet copied successfully!"

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

  • Tracy1 Profile Picture
    on at

    Thank you Vishnu, i will try this method.

    By the way, do you know how to click the Worksheet Tab by 'Variable"

    Input the 'Variable' in below Tab name.

    Tracy1_0-1720409800041.png

     

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @Tracy1 ,

     

    “Select tab in window” action in Power Automate Desktop does accept variables. You can use variables in selectors to dynamically interact with UI elements.

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

  • Tracy1 Profile Picture
    on at

    Hi Vishna,

    Could you please give me more details or example? 

    For example, the sheet tab variable is '%CurrentItem%', how to input it in the activity 'Select tab in Window'?

    Thanks & Regards,

    Tracy

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @Tracy1 ,

     

    You cant directly give %CurrentItem% under select Tab in window action as it supports only UI Element.If your slectors contains the Tab name there you can replace the Tabname with CurrentItem Variable.

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

  • Kaif_Siddique Profile Picture
    2,108 Super User 2024 Season 1 on at

    Hi @Tracy1 ,

     

    Use Copy Excel worksheet to copies a worksheet from an Excel document and paste it to the Excel document of the same or different Excel instance.

    Kaif_Siddique_0-1720423833334.png

     

    Kaif_Siddique_1-1720424041712.png

     

    Hope this will help you.

     

    Regards

    Kaif

     

  • Tracy1 Profile Picture
    on at

    Hi Kaif, 

    it works. Thanks.

    However when I use Copy Excel worksheet activity, I got below message and the Power Automate stopped. Do you know how to handle it?

    Tracy1_0-1720513074493.png

    Thank you.

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @Tracy1 ,

     

    The error message you’re seeing is occurring in Excel when you’re trying to copy a worksheet with a name that already exists in the destination workbook. Here’s how you can handle it:

    1. You can rename the worksheet before Copying the data using the Rename Excel worksheet action as shown below

    VishnuReddy1997_0-1720513645503.png

     


    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 299

#2
11manish Profile Picture

11manish 274 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 119

Last 30 days Overall leaderboard