简体   繁体   English

Excel:如何查找最后一个空单元格

[英]Excel: How to find the last empty Cell

In Excel, does anyone know how to look Upward from a given row to find the last blank Cell? 在Excel中,是否有人知道如何从给定的行向上查找以找到最后一个空白单元格?

I've got a strangely formatted excel export that I'm trying to report out of. 我正在尝试报告一个格式异常的excel导出。 However, i'm stuck trying to find an efficient formula to find the data. 但是,我一直在努力寻找一个有效的公式来查找数据。

Here are 2 examples of the exported format of this report. 这是此报告导出格式的2个示例。 For each "Item Number" it's listing all the parts it's used in. This might be just one SKU, or 15 SKUs, or none. 对于每个“项目编号”,它都会列出其使用的所有零件。这可能只是一个SKU或15个SKU,或者没有。 So this causes sub-header area to not be a consistent size. 因此,这将导致子标题区域的大小不一致。 Each new Item number gets this same format. 每个新的项目编号都采用相同的格式。 I've got 8000+ Item numbers, each output this same format. 我有8000多个项目编号,每个项目都以相同的格式输出。

here is the array formula: 这是数组公式:

{=INDEX($B$1:$B$70600,SMALL(IF("Item Number:"=$A$1:$A$70600,ROW($A$1:$A$70600)-ROW($A$1)+1),COUNTIF(INDIRECT("$A1:$A"&ROW()),"Item Number:")))}

My formula basically looks for the SKU (ie 35376) and reports back the above Item number it uses (ie 02859). 我的公式基本上是查找SKU(即35376)并报告其使用的上述物料编号(即02859)。 It does this by finding the row number of the SKU, and then counting the number of strings "Item number:" from the top to current row, and reports the last one. 它通过找到SKU的行号,然后计算从顶部到当前行的字符串“ Item number:”的数目来完成此操作,并报告最后一个。

** **

Created By:     Employee                    
Create Time:    01/08/2015 04:16:16 PM CST                      
    Where Used Report                       
Item Number:    02859                       
Description:    Packaging 35376                     
Level   Subclass    Number  Rev Description Find Num    Qty BOM Notes   
.. 2    SKU 45268   A        MCO-01101  Product Name    0   1       

Created By:     Employee                    
Create Time:    01/08/2015 04:16:16 PM CST                      
    Where Used Report                       
Item Number:    02858                       
Description:    Packaging 35345                     
Level   Subclass    Number  Rev Description Find Num    Qty BOM Notes
.. 2    SKU 35376   E        ECO-07812  Product name    0   1   
.. 2    SKU 39022   A        MCO-01198  Product Name    0   1   
.. 2    SKU 39033   A        MCO-01187  Product Name    0   1

** **

However, my current function is crashing out as i've got 70k rows it's searching through. 但是,由于要搜索的行有7万行,我当前的函数崩溃了。

What I'd rather do, is simply look UPWARDS in the sheet to find the row number of the last header value (ie "Number") or even just the last empty cell. 我想做的只是在工作表中向上查找以查找最后一个标头值(即“ Number”)的行号,甚至只是最后一个空单元格。 Instead, it seems that most of the functions are geared around looking down to the next value. 取而代之的是,似乎大多数功能都是围绕着查找下一个值而进行的。 Which forces me to look from the Top to the current row. 这迫使我从顶部到当前行。

Anyone know how to look Up from a given row to find the last blank Cell? 有人知道如何从给定的行中查找以查找最后一个空白单元格吗?

You can use LOOKUP in various ways to get the last occurrence of some value, eg this formula in row 100 will find the last instance of "Item Number:" in column A above and return the corresponding value from column B 您可以通过多种方式使用LOOKUP来获取某个值的最后一次出现,例如,第100行中的此公式将在上方的A列中找到“ Item Number:”的最后一个实例,并从B列返回相应的值

=LOOKUP(2,1/(A$1:A99="Item Number:"),B$1:B99)

This can be fast if you know how many rows you need to look at, eg if the previous "Item number" will always be within 30 rows you can set the range in the formula to look at only 30 rows 如果您知道需要查看多少行,这可能会很快,例如,如果以前的“商品编号”始终在30行之内,则可以在公式中将范围设置为仅查看30行

It's possible using SUMPRODUCT, but s it searches all 10xxxxx cells in a column, don't have too many, else the spreadsheet will slow to a crawl. 可以使用SUMPRODUCT,但是它会搜索一列中的所有10xxxxx单元格,不要太多,否则电子表格将慢速进行爬网。

=INDEX(B:B,SUMPRODUCT(MAX((A:A="Item Number:")*ROW(A:A))))

This will return the data in column B where the last "Item Number:" appears 这将返回B列中最后一个“项目编号:”出现的数据

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

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