View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Scott Scott is offline
external usenet poster
 
Posts: 149
Default Delete Columns based on Strings

sorry about that, thought i was loosing my mind. thx.

"Tom Ogilvy" wrote in message
...
I gave that code to you yesterday.

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
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