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
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