How to Only Delete Visible Rows or Columns in Excel?

Although deleting rows or columns in a spreadsheet can be a common activity, there are occasions when you might want to retain the hidden rows or columns in tact. When working with filtered data or removing specific data from a sizable dataset without altering the hidden information, this can be especially helpful.

We will examine the procedures for successfully completing this work in this tutorial. No of your level of Excel proficiency, you'll find the directions simple to follow and apply to your own projects. You will have a firm grasp on how to erase visible rows or columns in Excel without affecting the hidden data by the end of this course. So let's get started and explore the world of Excel where you'll discover how to just remove the rows or columns that are visible!

Only Delete Visible Rows or Columns

Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to learn how you can only delete visible rows or columns in Excel.

Step 1

Consider an Excel sheet where you have hidden rows and column.

First, right-click on the sheet name and select View code to open the VBA application.

Right Click > View Code.

Step 2

Then click on Insert, select Module, and copy the below code into the text box.

Insert > Module > Copy.


Sub DeleteVisibleRows()
Dim WorkRng As Range
On Error Resume Next
xTitleId = "Delete Visible Cells"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
Application.ScreenUpdating = True
End Sub

Step 3

Then click F5 to run the module. Then select the range of cells and click OK.

F5 > Select Cells > Ok.

This is how you can only delete visible rows or columns in Excel.


In this tutorial, we have used a simple example to demonstrate how you can only delete visible rows or columns in Excel to highlight a particular set of data.

Updated on: 06-Sep-2023


Kickstart Your Career

Get certified by completing the course

Get Started