Hi all,
I've been trying to add a date condition to the following macro, but not having much sucess.
I would like the macro in the following line:
If sh.Cells(i, 7).Value = "Y" Then
to also check if the date in column 1 is in April. I've tried
and replacing value with date, but no sucess.
Any ideas?
Thanks in advance guys
I've been trying to add a date condition to the following macro, but not having much sucess.
Code:
Public Sub Breaches()
Dim sh As Worksheet, _
dSh As Worksheet, _
shLR As Long, _
i As Long, _
shd As Long, _
shl As Long, _
dRow As Long
Application.ScreenUpdating = False
Set dSh = Sheets("Forcasting")
shd = 1
For Each sh In ActiveWorkbook.Worksheets
dRow = 2
Select Case sh.Name
Case "DifferenceData", "Breaches", "StDev", "Breaches and Date", "Forcasting"
'do nothing
Case Else
dSh.Cells(1, shd).Value = sh.Name
shLR = sh.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To shLR
If sh.Cells(i, 7).Value = "Y" Then
sh.Cells(i, 9).Copy Destination:=dSh.Cells(dRow, shd)
dRow = dRow + 1
End If
Next i
shd = shd + 1
End Select
Next sh
Application.ScreenUpdating = True
End Sub
I would like the macro in the following line:
If sh.Cells(i, 7).Value = "Y" Then
to also check if the date in column 1 is in April. I've tried
Code:
If sh.Cells(i, 1).Value < 31 / 4 / 2011 And sh.Cells(i, 1).Value > 1 / 4 / 2011 And sh.Cells(i, 7).Value = "Y" Then
Any ideas?
Thanks in advance guys