View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
MSchmidty2 MSchmidty2 is offline
external usenet poster
 
Posts: 13
Default Check Date, Include dates from rest of month and all of next m

Thanks for the reply and your help, Patrick. I'm a little rusty with VBA and
this code is definitely over my head. I receive a run-time error 13 'Type
Mismatch' when I attempt to run this macro, and I've tried to determine why,
but have been unsuccesful.

"Patrick Molloy" wrote:

Sub tester()


Dim keydate As Date
Dim yr As Long
Dim target As Range
Dim bremove As Boolean

'initialise date
keydate = DateSerial(Year(Range("B1").Value), Month(Range("B1").Value), 1)


Set target = Range("B2")
Do Until target.Value = ""
bremove = True
'check this month
If DateSerial(Year(target.Value), Month(target.Value), 1) = keydate Then
bremove = False
'check next month
ElseIf DateSerial(Year(target.Value), Month(target.Value) - 1, 1) =
keydate Then
bremove = False
End If
If bremove Then
Rows(target.Row).Delete
End If

Set target = target.ffset(1)
Loop

End Sub




"MSchmidty2" wrote in message
...
Hi,
I'm working on a chart which has a variety of job numbers in column a.
These job #'s are coupled with dates in column b. I need to check the
date
of the top cell in the column, and then keep the dates from the rest of
the
month from that date, and also the next month, while deleting the rest of
the
job #'s and dates beyond that. I can't hide the rows because there is
more
information that is needed. Any tips would be appreciated. Thanks!