UnsolvedCoding
Technical User
Why am I getting an error on line 100? The array is used in other subs without any problems and works fine everywhere else.
Sub New_Output_Array()
Dim RELAY As Boolean
On Error GoTo Error_Handler
100: Erase IO_OUTPUT_ARRAY
200: Erase RELAY_ARRAY
300: TEST = 1
400: COUNTER = 1
' Sets up starting row
500: A = 1
' Sets up starting column
600: C = 10
' Loop until the first cell in column B is empty
700: Do
' Go to the proper sheet
800: If IsEmpty(Sheets("Holding").Cells(A + 1, C).Value) Then Exit Do
' Count the number of cells holding a type
900: COUNTER = COUNTER + 1
' Get only the CR and CR4 count
1000: If Sheets("Holding").Cells(A + 1, C).Value = "CR" Or _
Sheets("Holding").Cells(A + 1, C).Value = "CR4" Then
1100: TEST = TEST + 1
1200: End If
' Go down one row
1300: A = A + 1
1400: Loop
' Set the variable
1500: I = 0
1600: J = 0
' Get ready to save the info
1700: ReDim IO_OUTPUT_ARRAY(3 * COUNTER)
1800: ReDim RELAY_ARRAY(3 * TEST)
1900: For A = 1 To COUNTER
2000: If Sheets("Holding").Cells(A, C).Value = "CR" Or _
Sheets("Holding").Cells(A, C).Value = "CR4" Then RELAY = True
' Put the nickname in the array
2100: IO_OUTPUT_ARRAY(I) = Sheets("Holding").Cells(A, C - 2).Value
2200: If RELAY = True Then _
RELAY_ARRAY(J) = Sheets("Holding").Cells(A, C - 2).Value
' Put the DESCRIPTION in the array
2300: IO_OUTPUT_ARRAY(I + 1) = Sheets("Holding").Cells(A, C - 1).Value
2400: If RELAY = True Then _
RELAY_ARRAY(J) = Sheets("Holding").Cells(A, C - 1).Value
' Put the TYPE in the array
2500: IO_OUTPUT_ARRAY(I + 2) = Sheets("Holding").Cells(A, C).Value
2600: If RELAY = True Then
2700: RELAY = False
2800: RELAY_ARRAY(J) = Sheets("Holding").Cells(A, C).Value
2900: J = J + 1
3000: End If
' Increase array by one
3100: I = I + 3
3200: Next A
3300: Exit Sub
Error_Handler:
Application.ScreenUpdating = True
FLAG = False
TEST2 = MsgBox("New_Output_Array Malfunctioned." & vbCrLf & _
"Error Number - " & Err.Number & vbCrLf & "Error Source - " & Err.Source & _
vbCrLf & "Error Description - " & Err.Description & _
vbCrLf & "Error Line: " & Erl & vbCrLf & "Help File - " & Err.HelpFile & _
vbCrLf & "Context - " & Err.HelpContext, vbOKOnly + vbCritical)
End Sub