-
Makes lots of assumptions:
[vba]FR = Evaluate("MIN(IF(MONTH(C:C)=8,ROW(C:C)))")
LR = Evaluate("Max(IF(MONTH(C:C)=8,ROW(C:C)))")
Range("A" & FR & ":E" & LR).Select
[/vba]Works on active sheet, assumes contiguous August cells, ignores year.
Will be slow 'cos it works on entire column C, but will speed up a lot if you replace C:C with likes of C1:C1000:
[vba]FR = Evaluate("MIN(IF(MONTH(C1:C1000)=8,ROW(C1:C1000)))")
LR = Evaluate("Max(IF(MONTH(C1:C1000)=8,ROW(C1:C1000)))")
Range("A" & FR & ":E" & LR).Select
[/vba]
These will be fooled with plain numbers such as 236 which can represent a date in Aug 1900.
Another method:
[VBA]LastRowOnSheet = ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count
For rw = 1 To LastRowOnSheet
If IsDate(Cells(rw, 3).Value) And Month(Cells(rw, 3).Value) = 8 Then
FR = rw
Exit For
End If
Next rw
For rw = rw + 1 To LastRowOnSheet
If Not (IsDate(Cells(rw, 3).Value)) Or Month(Cells(rw, 3)) <> 8 Then
LR = rw - 1
Exit For
End If
Next rw
Range("A" & FR & ":E" & LR).Select
[/VBA] Again, contiguous august cells etc.
Last edited by p45cal; 09-08-2011 at 02:59 PM.
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules