View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Scott Scott is offline
external usenet poster
 
Posts: 149
Default Looping Through Sheet

My Below Sub accepts a string, finds it and deletes the row in which the
string is found. Can someone help me modify it to continue searching through
all cells that contain data and delete any other rows where the string
occurs?

USAGE:

DeleteRowswString("myword")

CODE

Sub DeleteRowwString(ByVal sString As String)

Dim theRange As Range, nCells As Integer, I As Integer
Set theRange = Selection
nCells = theRange.Cells.Count
For I = nCells To 1 Step -1
If theRange.Cells(I).Value = sString Then
theRange.Cells(I).EntireRow.Delete
End If
Next
End Sub