If you are working with a large amount of data, and you want to delete columns with a specific heading, then using the right-click method on your mouse could take quite a while.
You can use VBA to do it a lot quicker.
- Enable the developer tab in Excel – the video below explains how:
- Hold down Alt key and F11 to bring up VBA editor
- Click insert – module
- Add the code:
For i = ActiveSheet.Columns.Count To 1 Step -1
If InStr(1, Cells(1, i), "position") Then Columns(i).EntireColumn.Delete
- Where the code says “position” change to the text you want i.e. header text that denotes a column to delete
- save as macro enabled workbook
By the way, the video above shows all the steps, not just how to install the developer tab.