Hi,
I need to:
1. Find a column containing the word 'target' in header. (from the range P1 to QI1 )
2. Delete all other column without 'target' in its header.
the code above is deleting all the column with the word 'target'.
thanks in advance.
I need to:
1. Find a column containing the word 'target' in header. (from the range P1 to QI1 )
2. Delete all other column without 'target' in its header.
Code:
Sub Cleanup()
Dim rng As Range
With ActiveSheet.Range("P1:QI1")
Set rng = ActiveSheet.Range("P1:QI1").Find(What:="target", _
LookAt:=xlPart, MatchCase:=False)
Do While Not rng Is Nothing
rng.EntireColumn.Delete
Set rng = .FindNext
Loop
End With
End Sub
the code above is deleting all the column with the word 'target'.
thanks in advance.