jim may
Well-known Member
- Joined
- Jul 4, 2004
- Messages
- 7,486
Code is bombing on code line in RED - what rule am I violating?
Rich (BB code):
Option Base 1
Sub Foo()
Dim arr1()
Dim arr2()
Dim Rng As Range
Dim FDate As Date
LR = Range("A" & Rows.Count).End(xlUp).Row
Set Rng = Range(Cells(2, 1), Cells(LR, 2))
arr1 = Rng
ReDim Preserve arr2(1, 2)
arr2(1, 1) = Cells(2, 1)
arr2(1, 2) = Cells(2, 2)
NumMonths = 1
FDate = arr1(1, 1)
For i = 3 To LR
If Month(Cells(i, 1)) <> Month(FDate) Then
NumMonths = NumMonths + 1
ReDim Preserve arr2(UBound(arr2, 1) + 1, 2)
arr2(NumMonths, 1) = Cells(i, 1)
arr2(NumMonths, 2) = Cells(i, 2)
FDate = DateSerial(Year(FDate), Month(FDate) + 1, 1)
End If
Next i
MsgBox arr2(1, 1) & " and " & arr2(1, 2)
MsgBox arr2(2, 1) & " and " & arr2(2, 2)
MsgBox arr2(3, 1) & " and " & arr2(3, 2)
MsgBox arr2(4, 1) & " and " & arr2(4, 2)
End Sub