How to Delete Blank Cells and Shift Data Up in Excel: 8 Methods

Method 1 – Deleting Blank Cells Manually

Steps:

  • Hover the cursor until a downward pointing arrow appears >> left-click to select the column, here it is Column C.

Deleting Blank Cells Manually

  • Click the Delete drop-down >> press Delete Sheet Columns.

Using Delete columns option

  • Hold down the CTRL Key >> left-click on the row numbers to select multiple rows, in this case, rows 7, 9, 12, and 14 >> choose the Delete Sheet Rows option.

Using Delete Sheet Rows

Remove blank cells in Excel and shift data up.

how to delete blank cells in excel and shift data up manually


Method 2 – Using Go To Special Command

Steps:

  • B4:E16 cells >> click Find & Select drop-down >> select Go To Special.

Using Go To Special Command

  • Go To Special window, click the Blanks button>> hit OK.

Selecting Blanks

  • Right-click to open the Context Menu >> choose Delete.

Pressing delete

  • Check the Shift cells up the option to remove all the blank rows.

how to delete blank cells in excel and shift cells up

  • Select the blank column >> select the Shift cells left option >> press OK.

Shift cells left

Deletes the blank cells as shown in the image below.

how to delete blank cells in excel and shift data up with Go To Special option


Method 3 – Utilizing Filter Option

Steps:

  • Highlight the B4:E16 cells >> move to the Data tab >> click the Filter option.

Utilizing Filter Option

  • Click any down-arrow button >> check the Blanks option >> enter the OK button.

Check the Blanks option

  • Delete Sheets Rows to remove all the blank rows.

Removing sheet rows

  • Click the down-arrow button >> check the Select All option >> click on OK.

Check Select All option

  • Select the blank column >> press Delete Sheet Columns.

Removing Sheet Columns

The results should look like the picture shown below.

how to delete blank cells in excel and shift data up with Filter option


Method 4 – Applying Sort Feature

Steps:

  • Select the B5:E16 cells >> navigate to the Data tab >>  click the Sort feature.

Applying Sort Feature

  • Select the blank rows >> use the CTRL + – (Minus) keys to delete them.

Using shortcut key to delete

  • Select the blank column >> press CTRL + – (Minus) keys to delete the column.

Your results should resemble the screenshot below.

how to delete blank cells in excel and shift data up with Sort feature


Method 5 – Employing Find Option

Steps:

  • Select the B5:E16 cells >> jump to the  Find option in the Find & Select drop-down.

Employing Find Option

  • Find and Replace, check the Match entire cell contents option >> in the Look in field, select Values option >> press Find All.

Using Find & Replace

  • The top result and press the CTRL + A keys to select all >> hit Close.

Using shortcut to select all

  • Apply the Delete Sheet Rows option.

The results should appear in the screenshot below.

how to delete blank cells in excel and shift data up with Find option


Method 6 – Incorporating Advanced Filter Menu

Steps:

  • Follow the steps shown in the animated GIF shown below.

Incorporating Advanced Filter Menu

The final output should look like the figure below.

how to delete blank cells in excel and shift data up with advanced filter


Method 7 – Using FILTER Function

Steps:

  • IChoose the B4:E16 cells >> press CTRL + T to insert Excel Table as shown below.

Using FILTER Function

  • Proceed to the Table Design tab >> rename the Table as “Best_Sellers”.

Renaming table

  • Move to the F5 cell >> insert the formula into the Formula Bar.

=FILTER(Best_Sellers,Best_Sellers[[Name ]]<>"" )

Formula Breakdown
  • FILTER(Best_Sellers,Best_Sellers[[Name ]]<>”” ) → filter a range or array. Here, Best_Sellers is the array argument, while Best_Sellers[[Name ]]<>”” is the include argument that removes the blank rows in the given array.

how to delete blank cells in excel and shift data up with FILTER function


Method 8 – Implementing PowerQuery Option

Steps:

  • Insert an Excel Table as shown previously >> go to the Data tab, and click the from Table/Range option.

Implementing PowerQuery Option

  • Follow the steps in real time as shown in the GIF.

Removing Rows in PowerQuery

  • Move to the Close & Load drop-down >> select the Close & Load To option.

Choosing Close & Load to option

  • Choose the Existing worksheet option and select the F4 cell.

Inserting table into existing sheets

The results should look like the screenshot below.

how to delete blank cells in excel and shift data up using PowerQuery


How to Delete Empty Cells and Shift Data Up Using Excel VBA

Steps:

  • Navigate to the Developer tab >> click the Visual Basic button.

How to Delete Empty Cells and Shift Data Up Using Excel VBA

This opens the Visual Basic Editor in a new window.

  • Go to the Insert tab >> select Module.

Inserting Module

Copy the code from here and paste it into the window below.

Sub Delete_blank_cells()

    With Range("B4:D16")
        If WorksheetFunction.CountA(.Cells) > 0 Then .SpecialCells(xlCellTypeBlanks).Delete Shift:=xlShiftUp
    End With
    
End Sub

VBA code for how to delete blank cells in excel and shift data up

Code Breakdown
  • The sub-routine is given a name, here it is Delete_blank_cells().
  • Use the With statement and Range property to set the range of the dataset.
  • Use the If statement and CountA function to check whether the cell is blank, in which case, use the Delete method to remove the blank rows.

Code explanation how to delete blank cells in excel and shift data up

  • Click the Run button or press the F5 key to execute the macro.

Running macro

The results should look like the image given below.

how to delete blank cells in excel and shift data up using VBA Code


How to Delete Blank Rows in Excel and Shift Data Up Using Formula

Steps:

  • Copy and paste the expression into the F5 cell.

=IFERROR(INDEX(B:B,SMALL(IF(B$5:B$16<>"",ROW(B$5:B$16)), ROWS(B$5:B5))), "")

The B5:B16 cells refer to the “Name” column.

Formula Breakdown
  • ROW(B$5:B$16) returns the serial number of the row.
    • Output → {5;6;7;8;9;10;11;12;13;14;15;16}
  • ROWS(B$5:B5)returns the total row numbers in the given range.
    • Output → 1
  • IF(B$5:B$16<>””,ROW(B$5:B$16)) → checks whether a condition is met and returns one value if TRUE and another value if FALSE. Here, B$5:B$16<>”” is the logical_test argument that checks the B5:B16 range for blanks. The function returns the ROW(B$5:B$16) if the test holds TRUE (value_if_true argument) otherwise it returns FALSE (value_if_false argument).
    • Output → {5;6;FALSE;8;FALSE;10;11;FALSE;13;FALSE;15;16}
  • SMALL(IF(B$5:B$16<>””,ROW(B$5:B$16)), ROWS(B$5:B5))becomes
    •  SMALL({5;6;FALSE;8;FALSE;10;11;FALSE;13;FALSE;15;16}) returns the kth smallest value in data set.
    • Output → 5
  • INDEX(B:B,SMALL(IF(B$5:B$16<>””,ROW(B$5:B$16)), ROWS(B$5:B5)))becomes
    • INDEX(B:B,5)returns a value at the intersection of a row and column in a given range. In this expression, the B:B is the array argument which is the “Name” column. Next, 5 is the row_num argument that indicates the row location.
    • Output“The Grass is Always Greener”
  • IFERROR(INDEX(B:B,SMALL(IF(B$5:B$16<>””,ROW(B$5:B$16)), ROWS(B$5:B5))), “”) → becomes
    • IFERROR(“The Grass is Always Greener”, “”)  → returns value_if_error if the expression has an error and the value of the expression itself otherwise. Here, “The Grass is Always Greener” is the value argument, and “” is the value_if_error argument.
    • Output → “The Grass is Always Greener”

How to Delete Blank Rows in Excel and Shift Data Up Using Formula

The results should look like the picture shown below.

how to delete blank cells in excel and shift data up with Formula


Download Practice Workbook


Related Articles


<< Go Back to Blank Cells | Excel Cells | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Maruf Islam
Maruf Islam

MARUF ISLAM is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including ABACUS, AutoCAD, Rhinoceros, Maxsurf, and Hydromax. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he creates techy content... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo