I am trying to add the value of a cell in an array, but i am getting a type mismatch error in my code. Why is this happening?
Dim rng As Range
Dim cell As Range
Dim arr As Variant
Set rng = Range("panel_is_on")
For Each cell In rng
If cell.Value2 = "On" Then
If cell.Offset(0, -1).Value2 = "ISJ" Or cell.Offset(0, -1).Value2 = "BSJ" Then
arr(i) = cell.Offset(0, -3).Value2
i = i + 1
End If
End If
Next cell
Debug.Print IsArray(arr)arris not an array -Dim arr() As Variantthenredim preservein the loop to extend it as needed.