Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Justas4478
Post Prodigy
Post Prodigy

Tidying excel spreadsheet in power query

Hi, I have excel file that has multiple tables in same sheet.
It has some other tables that I do not need, but there is not easy way to remove them since size of the tables can change every week so I cant just remove certain amount of rows from the bottom.

Justas4478_0-1763373115735.png

But one thing is consistent that whole area that I do not need is after and including row that has TOTAT STD & TOTAL STD2.
If it is possible some how to to use that to delete rows that have TOTAT STD and rows after that I would apreciate the help.

Thanks

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

I believe this task can be done easily with a simple VBA script. Attach it to a button for ease of use, if necessary.

 

The VBA Range.Find method will locate the row that contains TOTAT STD & TOTAL STD2.

Then just delete the rows (or the contents of the rows) below that.

 

If you want the desired table on a new sheet, then use the Range.Copy method to copy the rows up to and including the found row to the new sheet.

View solution in original post

3 REPLIES 3
m_dekorte
Super User
Super User

Hi @Justas4478,

Give this a go. Create a new blank query, name it: findFinalRow
Open the advanced editor for findFinalRow, select everything that is there and replace it with this:

(input, match) as logical =>
    Comparer.Equals( Comparer.OrdinalIgnoreCase,Text.From(input ?? ""), match)

 

Go back to the query with the data you brought in from the worksheet, make sure the last step is selected in the Applied Steps pane. Press the fx in front of the formula bar, this will insert a manual step into your query and show the identifier of the previous step from that query.

This is a bit tricky but copy this code and paste it inbetween the equals sign (=) and that identifier.

Table.RemoveLastN(
    Table.Skip( PutYourIdentifierHere, 
        each List.AnyTrue(
            List.Transform(
                Record.ToList(_), 
                (x)=> findFinalRow(x, "TOTAT STD"))
        )
    )
)

Your identifier can now be found after the final closing parenthesis of this expression, select and cut it. Next paste it in place of PutYourIdentifierHere.

I hope this is helpful.

 

PhilipTreacy
Super User
Super User

Hi @Justas4478 

 

Your request isn't very clear. and without seeing your file it's hard to know exactly how your data is organised.

 

If you have a table you don't want, then delete it?  Or am I missing some other detail?

 

As for those celsl that have the heading TOTAT STD, they are not in a table, I don't understand why you can't just delete those too.

 

Where does Power Query come  in?

 

Please supply your file.

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


ronrsnfld
Super User
Super User

I believe this task can be done easily with a simple VBA script. Attach it to a button for ease of use, if necessary.

 

The VBA Range.Find method will locate the row that contains TOTAT STD & TOTAL STD2.

Then just delete the rows (or the contents of the rows) below that.

 

If you want the desired table on a new sheet, then use the Range.Copy method to copy the rows up to and including the found row to the new sheet.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.