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 Automate
Unanswered

Data to Excel

(0) ShareShare
ReportReport
Posted on by 27

I have a data table with one column and seven rows. I want to write them in excel, like those seven rows should be in different columns(seven columns in one row in excel). Use less actions.

Screenshot 2024-03-25 124656.png
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Raju25 

     

    does this approach is fine ?

     

    suppose i have datatable dt1 like below

    Nived_Nambiar_0-1711378512614.png

     

    Now see how we transpose it 

    Nived_Nambiar_1-1711378539407.png

     

    Flow 

    SET headers TO []
    Variables.CreateNewDatatable InputTable: { ^['Column1'], [1], [2], [3], [4], [5], [6] } DataTable=> dt1
    Variables.RetrieveDataTableColumnIntoList DataTable: dt1 ColumnNameOrIndex: 0 ColumnAsList=> ColumnAsList
    LOOP FOREACH item IN ColumnAsList
     Variables.AddItemToList Item: 'Column' + item List: headers
    END
    SET dt2 TO { ^headers, ColumnAsList }
    

     

    Now see the resulatant dt2 which is transposed one >

    Nived_Nambiar_2-1711378587586.png

     

     

    Hope it 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! 🙌

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

    Hi @Raju25 ,

     

    Please find the attached solution.

    MicrosoftTeams-image.png

     

    VB Script:

     

    Const xlUp = -4162
    Const xlToLeft = -4159
    Dim objExcel, objWorkbook, objSheet
    Dim lastRow, rowData(), i
    ' Create Excel objects
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Pictures\Rows.xlsx") ' Update the path to your Excel file
    Set objSheet = objWorkbook.Sheets(1)
    Set objSheet2 = objWorkbook.Sheets(2)
    ' Find the last used row in column A
    lastRow = objSheet.Cells(objSheet.Rows.Count, 1).End(xlUp).Row
    ' Resize the array based on the number of rows
    ReDim rowData(lastRow)
    ' Read data from Excel sheet (assuming data is in column A)
    For i = 1 To lastRow
    rowData(i) = objSheet.Cells(i, 1).Value
    Next
    ' Write data to Excel sheet in a single row
    For i = 1 To lastRow
    objSheet2.Cells(1, i).Value = rowData(i)
    Next
    ' Clean up
    objWorkbook.Save
    objWorkbook.Close
    objExcel.Quit
    Set objSheet = Nothing
    Set objWorkbook = Nothing
    Set objExcel = Nothing

     

    (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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 245

#2
David_MA Profile Picture

David_MA 216 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 212

Last 30 days Overall leaderboard