View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Delete Rows with particular dates

Hi Al

With the dates in sheet2 in column A
Select the cells in column C in Sheet1 or ? before you run the sub

Try this example

Public Sub FindNDelete()
Dim myRange As Range
Dim myCell As Range
Dim findText As String
Dim i As Long
Dim found As Boolean
Application.ScreenUpdating = False
found = False
For i = 1 To Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
findText = Worksheets("Sheet2").Cells(i, 1)
Application.StatusBar = "Finding " & findText
Set myRange = Selection
Do
Set myCell = myRange.Find(What:=findText, _
LookIn:=xlFormulas, lookAt:=xlWhole)
If Not myCell Is Nothing Then
myCell = ""
found = True
End If
Loop Until myCell Is Nothing
Next i
If found Then
myRange.SpecialCells(xlCellTypeBlanks).EntireRow.D elete
End If
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Al Mackay" wrote in message om...
Is it possible to delete rows where dates that appear in column C,
have been defined within Sheet2 (basically delete bank holiday days
that I'll separately define in Sheet2).

Also, after these dates have then been deleted to go through and
delete any rows where the date is either day 6 or 7 (e.g. Saturday and
Sundays).

Thanks In Advance, Cheers - Al.