raghuprabhu
Registered User.
- Local time
- Yesterday, 19:52
- Joined
- Mar 24, 2008
- Messages
- 154
Hi All,
My work has banned Access. Now I have to convert to Excel just when I am about to retire.
I am trying to select rows within a date range, with the value of "No" in the fourth column.
I have highlighted the line of code, not working.
Please, someone, tell me what I am doing wrong!
Regards
Raghu
My work has banned Access. Now I have to convert to Excel just when I am about to retire.
I am trying to select rows within a date range, with the value of "No" in the fourth column.
I have highlighted the line of code, not working.
Please, someone, tell me what I am doing wrong!
Code:
Sub CreateReport()
Dim sDate As Date
Dim tDate As Date
Dim PayDay As Date
Dim DueDate As Date
Dim PayCal As String
Dim LastRow As Integer
Dim i As Integer
Sheets("PayPeriod").Select
sDate = Range("G2").Value
tDate = Range("G3").Value
PayDay = Range("G4").Value
PayCal = Range("G5").Value
Sheets("Member_List").Select
LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
DueDate = Cells(i, 2).Value
'********************************************************************************************************
'If (DueDate >= sDate And DueDate <= tDate) And (Cells(i, 4).Value = "No") Then <<< not working!!!
'********************************************************************************************************
If (DueDate >= sDate And DueDate <= tDate) Then 'And (Cells(i, 4).Value = "No") Then
Range(Cells(i, 1), Cells(i, 4)).Copy
Range("P100").End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulasAndNumberFormats
Application.CutCopyMode = False
Cells(i, 4).Value = "Yes"
End If
Next i
End Sub
Regards
Raghu