
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Delete Entire Columns Based on Header Value in Excel
Microsoft Excel is a robust spreadsheet programme with numerous tools for data management and analysis. Delete columns based on certain criteria, such as the value in the header row, is a regular operation. In this lesson, we will walk you through the process of deleting entire columns based on header values using Excel's built-in functions and features. This strategy can help you quickly remove unneeded columns and optimise your data, whether you have a large dataset or a tiny table.
By the end of this tutorial, you will understand how to find and delete columns based on header values, allowing you to manage and organise your Excel data more efficiently. So, let's get started and see how we can complete this assignment in just a few simple steps!
Delete Entire Columns Based on Header Value
Here we will first create a VBA module, then run it to delete the column. So let us see a simple process to learn how you can delete entire columns based on header values in Excel.
Step 1
Consider an Excel sheet where you have the data in table format, similar to the below image.
First, right-click on the sheet name and click 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.
Example
Sub DeleteSpecifcColumn() Set MR = Range("A1:C1") For Each cell In MR If cell.Value = "Tax" Then cell.EntireColumn.Delete Next End Sub
In the code, Tax is the header value of the column and A1:C1 is the range of headers that will be deleted.
Step 3
Then, click F5 to run the module and complete the task.
Conclusion
In this tutorial, we have used a simple example to demonstrate how you can delete entire columns based on header values in Excel to highlight a particular set of data.