View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Creating Parameter Fields

Let's say your data is in cells D2:D100. There is a way to determine the
last row, but for now, I'll hard code it.

Sub Test()
Dim myRange As Range
Dim DeleteRange As Range
Dim r As Range

Set myRange = Range("D2:D100")

Set DeleteRange = Nothing
If r.Value DateSerial(2007, 3, 1) Or r.Value < DateSerial(2007, 4, 1) Then
If DeleteRange Is Nothing Then
DeleteRange = r
Else
DeleteRange = Union(DeleteRange, r)
End If
End If

Application.DisplayAlerts = False
If Not DeleteRange Is Nothing Then
DeleteRange.EntireRow.Delete
End If
Application.DisplayAlerts = True
End Sub


Modify to suit. I've got it deleting the entire row. I'm not sure if
that's what you want or not.

HTH,
Barb Reinhardt
"Naraine Ramkirath" wrote:

Hello All,

I have a simple spreadsheet with approx 500 records. I would like to have
this data sorted by column D and delete all records that is outside of two
parameter dates. Question: how do I create a parameter field using VBA?



Naraine