Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
delete columns based on selection | Excel Discussion (Misc queries) | |||
How to delete duplicates based on data in 2 columns? | Excel Discussion (Misc queries) | |||
How can I delete a row based on Columns H and I | Excel Programming | |||
How can I delete a row based on Columns H and I | Excel Programming | |||
Delete Columns based on a condition | Excel Programming |