I am trying to build an array of ranges from specific values along the column. I need to work with the cells between the values and this seems like the easiest way to accomplish it. The value is always the same, but how many there are in the column can change. I've found a lot of information on assigning values to an array, or creating an array from a contiguous range of cells, but not to assign specific cells to an array.
Below is the code I've been working on. I get a type mismatch error in the For loop on the aRng(x) = Cell.
Sub CellsToArray()
'Objects
Dim ws As Worksheet: Set ws = ActiveSheet
Dim Cell As Range, xRng As Range
'Arrays
Dim aRng() As Variant
'Variables
Dim LastRow As Long, x As Long
'Inialize
LastRow = ws.UsedRange.rows.Count
Set xRng = ws.Range("A1:A" & LastRow)
x = 0
'Populate the array
For Each Cell In xRng
If InStr(Cell.Value, "Item Number") > 0 Then
aRng(x) = Cell
x = x + 1
End If
Next Cell
For x = 0 To UBound(aRng)
Debug.Print aRng(x).Address
Next x
End Sub