Hello
In my spreadsheet I want to delete columns which have "pension" contained in any header cells.
[pre]Dim rng As Range
Dim cell As Range
Dim ContainWord As String
'What range do you want to search?
Set rng = Range("A1:HZ1")
'What phrase do you want to test for?
ContainWord = "Pension"
'Loop through each cell in range and test cell contents
For Each cell In rng.Cells
If cell.Find(ContainWord) Then ActiveCell.EntireColumn.Delete
Next cell[/pre]
This is what I have so far, but it's stopping at the If Cell.Find bit. I've used some sites to cobble together what I have but I've come to a dead end. Everything I've looked at is for deleting rows, not columns.
thank you for helping
____________
Pendle
In my spreadsheet I want to delete columns which have "pension" contained in any header cells.
[pre]Dim rng As Range
Dim cell As Range
Dim ContainWord As String
'What range do you want to search?
Set rng = Range("A1:HZ1")
'What phrase do you want to test for?
ContainWord = "Pension"
'Loop through each cell in range and test cell contents
For Each cell In rng.Cells
If cell.Find(ContainWord) Then ActiveCell.EntireColumn.Delete
Next cell[/pre]
This is what I have so far, but it's stopping at the If Cell.Find bit. I've used some sites to cobble together what I have but I've come to a dead end. Everything I've looked at is for deleting rows, not columns.
thank you for helping
____________
Pendle