How to Extract or Filter exclude blank values

Let’s suppose that you have assigned a task in which you need to filter out the values by excluding the blank values from the list having few values, and I am also pretty sure about it that you would definitely choose to do it manually, which is also a great choice when you have only a few values in a list, and you want to filter them out by excluding the blank values.

But if you are dealing with multiple values in the list and you want to filter them out by excluding all the blank cells, then in such a situation doing these tasks manually would be a foolish act because doing it manually, there are 95% chances that you would 100% get bored of it and can’t complete your task at the right time.

But you don’t need to worry about it because after carefully reading this article filtering out the blank values from the list containing multiple values would become very easy for you.

extract data by excluding blank value1

So let’s go deep into the article to take you out of this problem.

1. Extract or Filter exclude blank values using Formula

The Following formula would help you to Filter exclude the blank values in MS Excel:

=FILTER(total_data,(range1<>"")*( range2<>"")*( range3<>"")

Before explaining the formula for getting the work done efficiently, we must understand each syntax, which would make it easy for us that how each syntax contributes to filtering out the top n values in MS Excel.

  • Filter: This function contributes to narrowing down or filtering out a range of data on the user-defined criteria.
  • Comma symbol (,): In Excel, this comma symbol acts as a separator that helps to separate a list of values.
  • RangeN: is nothing but representing each column from the list.
  • Parenthesis (): The core purpose of this Parenthesis symbol is to group the elements and separate them from the rest of the elements.
  • total_data: In your worksheet, it represents the input ranges.

For instance, you got a task in which there is a table where you have candidates of two regions (i.e., West and East ) and which are assigned to a particular sales number, now you want to filter out the values by excluding all the blank cells, now let’s analyze that how to to write the formula and how this formula would do it.

As to filter exclude blank values, we would write the formula according to the given list like:

=FILTER(A2:C10,(A2:A10<>"")*(B2:B10<>"")*(C2:C10<>""))
extract data by excluding blank value1

The result from this formula would be a list of all data without any blank cell in between them.

The FILTER function extracts data that fits one or more criteria. In this scenario, we wish to use criteria that need data in all three source data columns.It means that if any of these values are missing from a row, that row should be exclude from the last result.

So in order to achieve the result, we have to use three boolean expressions that operate on arrays in Filter formula. The first expression checks for empty employee names:

A2:A10<>"" // check employee names

The “not equal” operator (<>) used with an empty string (“”) means “not blank values”. The result for each cell in the range A2:A10 will be TRUE or FALSE, where TRUE indicates “not empty” and FALSE means “empty.” Because the range has 9 cells, we obtain 9 results in an array-like as follows:

={TRUE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE}
extract data by excluding blank value1

The 2nd expression test for blank regions is as follows:

B2:B10<>"" / check regions

the result is as below:

={FALSE;TRUE;TRUE;TRUE;TRUE;FALSE;TRUE;TRUE;TRUE}
extract data by excluding blank value1

Last, we look for empty sale numbers:

C2:C10<>"" / check Sales

which results in:

={TRUE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;FALSE;TRUE}
extract data by excluding blank value1
=(A2:A10<>"")*(B2:B10<>"")*(C2:C10<>"")

When the three formulas above are multiplied, the arithmetic process converts the TRUE and FALSE values to 1 and 0. In this situation, we employ multiplication to enforce “AND” logic: expression1 AND expression2 AND expression3. In other words, in a given row, all three expressions must return True.

The end outcome, according to the laws of boolean logic, is an array like this:

={0;1;0;0;1;0;1;0;1}
extract data by excluding blank value1

This array is passed straight to the FILTER function as the include parameter to filter out all data excluding rows that have blank values.

2. Extract or Filter exclude blank values using VBA Code

Let’s see the second method, we’ll utilize VBA to automate the process of excluding blank values.

Open the Visual Basic for Applications (VBA) Editor by Pressing Alt + F11 to open the VBA editor.

In the VBA editor, click Insert in the menu, then select Module to create a new module.

Copy and paste the provided VBA code into the module.

Sub ExcludeBlanks()
    On Error Resume Next
    Dim selectedRange As Range
    Set selectedRange = Application.InputBox("Select the range of cells:", Type:=8)
    On Error GoTo 0

    If Not selectedRange Is Nothing Then
        On Error Resume Next
        Dim destinationCell As Range
        Set destinationCell = Application.InputBox("Select the destination cell for the results:", Type:=8)
        On Error GoTo 0

        If Not destinationCell Is Nothing Then
            Dim row As Range
            Dim hasBlank As Boolean
            Dim resultRange As Range

            For Each row In selectedRange.Rows
                hasBlank = False
                For Each cell In row.Cells
                    If cell.Value = "" Then
                        hasBlank = True
                        Exit For
                    End If
                Next cell

                If Not hasBlank Then
                    If resultRange Is Nothing Then
                        Set resultRange = row
                    Else
                        Set resultRange = Union(resultRange, row)
                    End If
                End If
            Next row

            If Not resultRange Is Nothing Then
                resultRange.Copy destinationCell
            Else
                MsgBox "No rows without blank cells found.", vbInformation
            End If
        End If
    End If
End Sub


Close the VBA editor to return to Excel.

Press Alt + F8 to open the Macro dialog.

Select the macro named “ExcludeBlanks”

and click Run.

A dialog will prompt you to select the range of cells containing data.

Click OK after selecting the range.

Another dialog will prompt you to select the destination cell for the results.

Click OK after selecting the destination.

The rows without any blank cells from the selected range will be copied and pasted into the specified destination cell.

3. Video: Extract or Filter exclude blank values

This Excel video tutorial, we’ll explore two distinct methods for extracting or filtering out blank values from your data. Our first approach involves using a dynamic formula, specifically the FILTER function, while the second method employs VBA (Visual Basic for Applications) code.

4. Related Functions

  • Excel Filter function
    The Excel  FILTER function extracts matched records from a collection of data using one or more logical checks. The include argument specifies logical tests, which might encompass a wide variety of formula conditions.==FILTER(array,include,[if empty])…