HOw to delete columns that contain text

kimsa

New Member
Joined
Feb 26, 2016
Messages
15
I want to delete the column if any of the cells in row 1 contain the text alternatetitle or articletype or conferenceinformation or publisher or issue etc. I have about 40 different words. How do I write the code to do this?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Put the words in a list on a separate sheet and name it "Words", then you can run this procedure:

Sub delCol()
For i = Range("XFD1").End(xlToLeft).Column To 1 Step -1
For j = 1 To Range("Words").Rows.Count
If InStr(Cells(1, i), Range("Words").Offset(j - 1, 0).Resize(1, 1).Value) > 0 Then
Columns(i).Delete
End If
Next
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,553
Messages
6,125,483
Members
449,233
Latest member
Deardevil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top