简体   繁体   中英

Excel - Delete rows if formula returns “”

The forumla I'm using is

=IF(E7<30,E7,"")

Edit:More specifically:

 =IF(E7<30,CONCATENATE(A7,B7,C7,"-",TEXT(D7,"hh:mm:ss"),"-",E7),"")

This leaves me with a lot of blank rows out of 288000 of them. I would like to be able to see all the cells that have a returned value together. Rather than having to scroll through all of them. I've tried using the find and replace method, but of course the cells still contain the formula, not the actual return value that it displays.

Sample.

15  Mar 2015    00:23:00    100.024         
15  Mar 2015    00:24:00    90.033          
15  Mar 2015    00:25:00    80.142          
15  Mar 2015    00:26:00    70.577          
15  Mar 2015    00:27:00    61.508          
15  Mar 2015    00:28:00    53.056          
15  Mar 2015    00:29:00    45.312          
15  Mar 2015    00:30:00    38.368          
15  Mar 2015    00:31:00    32.347          
15  Mar 2015    00:32:00    27.443          15Mar2015-00:32:00-27.443
15  Mar 2015    00:33:00    23.934          15Mar2015-00:33:00-23.934   
15  Mar 2015    00:34:00    22.117          15Mar2015-00:34:00-22.117
15  Mar 2015    00:35:00    22.111          15Mar2015-00:35:00-22.111
15  Mar 2015    00:36:00    23.695          15Mar2015-00:36:00-23.695
15  Mar 2015    00:37:00    26.43           15Mar2015-00:37:00-26.43
15  Mar 2015    00:38:00    29.895          15Mar2015-00:38:00-29.895

This is a better job for VBA- if you want to take a list and condense it you will have to use an array function- which is extremely heavy.. this function would return your rows in a condensed way - but would also break your workbook for 288,000 rows --

CTRL SHIFT ENTER ->

   =SMALL(IFERROR(1/($E$5:$E$20<30)*ROW($E$5:$E$20),""), ROWS($F$4:F4))

That's only going to give you the row number - so then you could write a function next to it referencing the results like so:

=CONCATENATE(INDIRECT("A"&F5),INDIRECT("B"&F5),INDIRECT("C"&F5),"-",TEXT(D5,"hh:mm:ss"),"-",INDIRECT("E"&5))

index function could work too.. VBA is really the way to solve this.

if you are inclined on doing it with formulas you may be able to get away with creating an if statement adjacent to the dataset like so: (formula presumed to be in column F)

 if(E5<30, max(f$4:f$4)+1, "")

then do an index formula like this

 index(A$5:A$10000, match(rows(l$5:l5), $F$5:$F$10000, 0))

then carry that formula over

then run your concat on that...

This is not recommended tho. Let me know if you want a VBA answer instead.

we can make a short cut to run this routine(it assumes your data starts at A2 btw). Let me know.

Sub Under30()
row1 = 2 ''starting row number
row2 = row1
Do While Cells(row1, 1) <> ""
        If Cells(row1, 5) < 30 Then
            'if e column is less than 30
            myTime = Application.WorksheetFunction.Text(Cells(row1, 4),"hh:mm:ss")
            Cells(row2, 6) = Cells(row1, 1) & Cells(row2, 2) & Cells(row1, 3) & "-" & myTime & "-" & Cells(row1, 5)
            row2 = row2 + 1
        End If
            row1 = row1 + 1
Loop
End Sub

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