Hi,
how do I append an item to an array without knowing how many to add to ahead of time? I created a generic example to illustrate.
how do I append an item to an array without knowing how many to add to ahead of time? I created a generic example to illustrate.
Code:
Public Sub Add2Arr()
Set sht = ThisWorkbook.Worksheets("Sheet1")
lastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
Dim maxArr() As Variant
For i = 1 To lastRow
If sht.Range("A" & i).Value Mod 2 = 0 Then
'append to maxArr() array then find the max of even numbers
Else
'append to maxArr() array then find the max of odd numbers
End If
Next
End Sub