简体   繁体   English

强制将空单元格移到已排序列的末尾

[英]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. 最好是在查询中按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" 我在题为“ 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. 那里的答案将获取工作表数据范围的值,并与values数组一起使用,然后将其放回该范围。 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)). 您可能需要构建一个要在每条要返回的行中添加内容的帮助程序列(例如我的Col7(G列))。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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