You will need to enable the Developer Tab in excel settings
Once enabled – Alt + F11 will open the code (Visual Basic) editor.
Add the code below:
Sub DeleteColumns() Dim i As Integer, A As Range For i = 100 To 1 Step -1 Set A = Cells(1, i).Find(What:="position", LookIn:=xlValues) If Not A Is Nothing Then A.EntireColumn.Delete Next i End Sub
Save as a Macro-enabled workbook.
Click on the Developer Tab again
Then click Macros and doubleclick on – Sheet1.DeleteColumns (this should be the default name of the macro that you just made)
The 3rd line of the code determines how many columns are ‘looked at’
For i = 100 To 1 Step -1
This formula will look in the first 100 columns
The 4th line of code
Set A = Cells(1, i).Find(What:="position", LookIn:=xlValues)
“position” is the default text to find – this code will find and delete those columns that contain “position”.
Change the “position” text to whatever it is you are looking up and want to delete.