简体   繁体   中英

force empty cells to end of sorted column

I want to sort a sheet by a column that has strings in it. I'm populating the sheet by putting a query based on an import range in the first cell. It seemed best if I did the sort as part of the query, order by Col6. This places all the empty rows at the top unless I sort descending, which I do not want to do. I found the opposite of what I want to do in the question titled "sort-empty-cells-to-top"

The answer there gets the values of the sheet's data range and works with the values array, then puts it back into the range. How would I change the compare function to force empty cells to the bottom in an ascending sort?

This might do what you want. You may have to build a helper column with somrthing in each row you want to return (like my Col7 (column G)).

=query(query(Sheet1!A1:G,"select * order by F "),"Select * where Col7 <>''")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM