Dear Excel Experts,
I have a simple piece of VBA code with some (messy) error handling that builds a collection by constructing a string and seeing if it exists in a larger collection.
This code generates an application execution error on the second pass through the for next loop.
I have a simple piece of VBA code with some (messy) error handling that builds a collection by constructing a string and seeing if it exists in a larger collection.
This code generates an application execution error on the second pass through the for next loop.
Code:
Private Sub UserForm_Initialize()
Dim i As Long
Dim Product As String
Dim PCores As Collection
If MyTools.PLProducts.count = 0 Then Call ConfiguratorMain.DataLoader
Resum:
ConfidentialL.Caption = ConfiguratorMain.ConfidentialL.Caption
OutputLB.ColumnCount = 4
OutputLB.TextAlign = fmTextAlignRight
Set PCores = New Collection
On Error GoTo eh 'If the constructed product name doesn't exist in the collection, then skip
For i = 1 To 2 ^ 16
Product = "5TB-XFD-" & i
If MyTools.PLProducts(Product) Then
PCores.Add i
End If
eh:
Next
On Error GoTo 0
End Sub