如何清除IMPORTRANGE导入两个表格间的空行并实现自动更新?
解决方案
可行性与自动同步说明
完全可行,且当源表格数据更新时,主表格会自动同步调整——因为IMPORTRANGE和QUERY都是谷歌表格的动态函数,会随数据源变化实时刷新。
修改后的公式
只需在原QUERY语句中添加WHERE条件,过滤掉所有列均为空的行(即两个数据集之间的空行),同时保留那些部分单元格为空、但至少有一个单元格非空的行(数据集内部的空白单元格):
=QUERY( {IMPORTRANGE("179zBHujwfCU-RX5378E7u5lfiVc5sNlK95ikemijRkY","'7 May 2024 - 20 May 2024'!H253:X270"); IMPORTRANGE("1AVAPqGRvAffQ1ANAdjzU5cYMGLvXIqZqy8CgsAqxZLM","'7 May 2024 - 20 May 2024'!I74:Y100")}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14,Col15,Col16,Col17 where Col1 is not null or Col2 is not null or Col3 is not null or Col4 is not null or Col5 is not null or Col6 is not null or Col7 is not null or Col8 is not null or Col9 is not null or Col10 is not null or Col11 is not null or Col12 is not null or Col13 is not null or Col14 is not null or Col15 is not null or Col16 is not null or Col17 is not null" )
原理说明
原公式中两个数据集之间的空行是整行所有列均为空的行,而数据集内部的空白单元格只是部分列空、其他列有内容。添加的WHERE条件通过检查每一列是否非空(只要有一列非空就保留该行),精准过滤掉了那些完全空的行,同时保留了有内容的行(即使其中部分单元格为空)。
内容的提问来源于stack exchange,提问作者Mahesh Methal
相关产品推荐
相关产品推荐

