Search code examples
excelexcel-formulaexcel-lambda

Excel formula to remove the empty rows at the bottom from a range


In Excel, I have a range B4:E100 in a worksheet, assume the content is like the follows. I'm looking for a formula (as simple as possible, with new Excel functions probably) that returns B4:E8, because there is nothing below row 8.

Does anyone know how to write such a formula that takes B4:E100 as input?

enter image description here


Solution

  • Try using the TRIMRANGE() function or its reference operators:

    enter image description here


    • Formula used in cell G4

    =LET(a, B4:.E100, IF(a=0,"",a))
    

    Or,

    =LET(a, TRIMRANGE(B4:E100,2), IF(a=0,"",a))
    

    Can read here more on the said function: TRIMRANGE() Function