Tim_Excel_
Well-known Member
- Joined
- Jul 12, 2016
- Messages
- 512
Hi forum
I am trying to populate an array in a loop. However, out of inexperience with arrays, I can't seem to populate my array.
In short: If the cell in the range is not empty and the header's first character is a number, then populate the array with the first numbers in that header. Then go to the next cell and repeat the process.
The code is breaking on the line that is supposed to fill the array (Type Mismatch).
I am trying to populate an array in a loop. However, out of inexperience with arrays, I can't seem to populate my array.
Code:
Dim SuppressArray As Variant
i = 1
For Each c In m_wb.Sheets("Componenten").Range(Cells(cell.Row, "N"), Cells(cell.Row, LCol))
If c.Value <> "" And IsNumeric(Left(m_wb.Sheets("Componenten").Cells(1, c.Column), 1)) = True Then
SuppressArray(i) = Left(m_wb.Sheets("Componenten").Cells(1, c.Column), InStr(1, m_wb.Sheets("Componenten").Cells(1, c.Column), "M") - 1)
i = i + 1
End If
Next c
If i = 1 Then GoTo nosuppress
In short: If the cell in the range is not empty and the header's first character is a number, then populate the array with the first numbers in that header. Then go to the next cell and repeat the process.
The code is breaking on the line that is supposed to fill the array (Type Mismatch).