LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default 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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete columns based on selection Steve Excel Discussion (Misc queries) 0 December 7th 09 09:38 PM
How to delete duplicates based on data in 2 columns? Max Excel Discussion (Misc queries) 2 April 9th 08 04:46 PM
How can I delete a row based on Columns H and I ICSAnalyst[_3_] Excel Programming 1 November 16th 04 10:19 AM
How can I delete a row based on Columns H and I ICSAnalyst[_4_] Excel Programming 1 November 15th 04 09:15 PM
Delete Columns based on a condition Joel Mills Excel Programming 3 August 6th 04 07:21 PM


All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"