![]() |
Delete Columns based on Strings
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 |
Delete Columns based on Strings
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 |
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 |
All times are GMT +1. The time now is 01:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com