View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Living the Dream Living the Dream is offline
external usenet poster
 
Posts: 151
Default Please Help! Delete all cells in range except "1934 - 1934"

Hi

Lets assume your sheet is the following:

mySht is the Name of your Sheet
myRng is the Range of the column that the code has to run down
myVal is the Date string match that you want to find in myRng
c represents every Cell within myRng

Change the above to fit the code below.

Sub RemoveGarbage()

Dim mySht As Worksheet
Dim myRng As Range
Dim myVal As Range
Dim c As Range

Set mySht = Sheets("Sheet1")
Set myRng = mySht.Range("F2:F10")
Set myVal = [F1]

For Each c In myRng
If Not c < myVal Then
With c
.EntireRow.Delete xlUp
End With
End If
Next c

End Sub

HTH
Mick.