Delete Columns based on Strings

S

scott

The below sub deletes rows containing strings. Can someone help me modify
it to delete columns if a string appears within the column?

Sub DeleteRowswString(ByVal sString As String)

Dim theRange As Range, nCells As Integer, I As Integer
Set theRange = Intersect(ActiveSheet.UsedRange.EntireRow, _
ActiveSheet.Columns(1)).Cells
nCells = theRange.Rows(theRange.Rows.Count).Row

For I = nCells To 1 Step -1
If Application.CountIf(Cells(I, 1).EntireRow, "*" & sString _
& "*") > 0 Then
Cells(I, 1).EntireRow.Delete
End If
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top