简体   繁体   中英

Formula to show only cells with a value and remove blank rows

I have a list that's two columns wide that has blank rows in then I'm trying to make a second list that shows only the rows with text in column "B" if column "C" also has a value at the same time removing the blank rows. For example here's my list:

在此处输入图片说明

sheet 1 is my list and list 2 is how I would like it to look.

I'm correctly using this formula:

=IF(ROWS($B$4:B4)>COUNTA($B$4:$B$13),"",INDEX($B$4:$B$13,AGGREGATE(15,6,(ROW($B$4:$B$13)-ROW($B$4)+1)/($B$4:$B$13<>""),ROWS($B$4:B4))))

which removed the blank rows but it shows black cells in column "C" for example:

在此处输入图片说明

You can use the following:

For the Item: =IFERROR(INDEX(G$1:G$5,SMALL(IF(H$1:H$5<>"",ROW(G$1:G$5)-ROW(G$1)+1),ROWS(G$1:G1))),"")

For the Qty: =IFERROR(INDEX(H$1:H$5,SMALL(IF(H$1:H$5<>"",ROW(G$1:G$5)-ROW(G$1)+1),ROWS(G$1:G1))),"")

Here's a screenshot of how I set up the data, so you can adjust the ranges in those formulas:

在此处输入图片说明

That's the formula for the Item. The only change to get the number, is change the column in the If statement from G$1:G$5 to H$1:H$5 .

Enter these formulas as an array formula ( CTRL+SHIFT+ENTER ) If you put these formulas and drag down a column, you can get your table updated dynamically, as IDs are added next to the Items:

在此处输入图片说明

And, just FYI if you want to reverse the results, just change Small to Large in the formula.

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