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 / Delete Top 6 Rows - De...
Power Automate
Answered

Delete Top 6 Rows - Delete Column C, E, F, G, H, I - Delete the all the subtotal and the Garbage at the bottom of the file

(0) ShareShare
ReportReport
Posted on by Super User 2024 Season 1

Hi,

I am trying to delete that single file and I am not successful. When I ran the script it deletes the top 6 rows as I expected, but it left the column 31-60 Days and 91+Days.  Also, it delete the garbage at the bottom of the file, but it left the grand total.  I tried everything and I know if the script correct.  Is anyone have a better idea, can you please share your answer as PAD so I can see the step.  I am sharing the file and my script as well and thank you an advance. 

*** THE ORIGINAL FILE IS AN .CSV EXTENSION AND I NEED TO SAVE AS .XLSX

I try to drag the entire file, but the forum is not supported .csv file.

1.  THIS IS THE TOP FILE

TTC_0-1682685947554.png

2. BOTTOM FILE

TTC_1-1682686037622.png

3. SCRIPT

TTC_2-1682686107686.pngTTC_3-1682686160456.png

AFTER SCRIPT RAN - TOP FILE

TTC_0-1682686467045.png

BOTTOM FILE

TTC_1-1682686520547.png

 

I have the same question (0)
  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @TTC 

     

    For column you made a logical mistake, using the action to delete column, when you delete a C column using the action, D column will moved to C column section, so all columns from C will move to their previous column

    like D >C

          E >D
          F>E
          etc.........

     

    So when you need to delete the E column as per original excel file, its position have changed to D column, so instead of delete Column E, you have to use delete Column D instead. So likewise you have to change that.

     

    So in your case it would be 

    Nived_Nambiar_0-1682697658505.png

     

     

    For rows, try this approach

    Nived_Nambiar_1-1682697787227.png

     

     

     

    Hope this helps

     

    Mark it as solution if it resolves your query 🙂

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Hi Nived,

    Thank you so much.  All the columns are gone except the Grand total is still showing.

    TTC_0-1682706983704.png

     

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

    Hi @TTC 

     

    If you look at your script (power automate code), you are first finding first free rows/column of an active worksheet and then making R&L Carriers as active worksheet  so before making R&L Carriers as active worksheet  some other sheet in workbook will be considered as active worksheet which have given their free row instead of R&L Carriers worksheet 

     

    So place set active worksheet action before get first free rows/column of excel action so that it can work correctly 

    Hope it helps !

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    I did put it before 'Get first free column' and it still the same.  I am not sure if this is where you want me to place it in the script.

    TTC_0-1682710179065.png

     

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

    Ok @TTC 

     

    May i know what is the value of FirstFreeRow variable ?

    Also are you seeing any rows being deleted ?

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Per my screenshot the only rows that been deleted are the columns.  The total at the bottom is still remain.

    Below are the first delete with the FirstFreeRow -1 and next one is -3

     

    TTC_0-1682807090603.png

    *** Do you think it because the file in .csv extension is the reason why it won't delete the Grand total at the bottom?

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

    Hi @TTC 

     

    Could you check what is the value of firstfreerow variable ?

    Nived_Nambiar_0-1682819785352.png

     

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    It look like it takes the first garbage on file and leave the total. This is the original file before everything.

     

    TTC_4-1682889004334.png

    TTC_5-1682889054258.png

     

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    The only way I can see the total is deleting, if I used the action 'Delete from Excel worksheet' instead 'Delete row from Excel worksheet' and I have to put the last row by hand.  If I use the variable %FirstFreeRow-1% it does not work for me. Something is causing the grand total not deleted at the bottom of the file and I cannot figure what is the root of the issue.

    TTC_2-1682888509453.pngTTC_3-1682888540082.png

     

     

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Hi Nived,

    It looks like I got it.  I counted from row 444 and up that give me 9 rows up.  Then I put -9 on the second action 'Delete row from Excel worksheet' and then I ran the script one last time and now the Grand Total is gone.  And it looks like I don't even need the first action %FirstFreeRow-1%. Please let me know if my approach is correct of if you're thinking to do it a different way.  Thanks!

    TTC_6-1682889872872.pngTTC_7-1682889903689.png

     

     

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 258 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 198 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 136 Super User 2026 Season 2

Last 30 days Overall leaderboard