Hello Everyone,
I hope you are well,
So I have a form that has been working perfectly, but I have added some more code to it and now I am getting the Runtime Error 9 coming up.
The form writes to an another workbook and the below still does that but then throws up an error.
*****the code that adds boxes dynamically in a form*****
I hope you are well,
So I have a form that has been working perfectly, but I have added some more code to it and now I am getting the Runtime Error 9 coming up.
The form writes to an another workbook and the below still does that but then throws up an error.
Code:
Dim trtt_label() As MSForms.Label
Dim trt_box() As MSForms.ComboBox
Code:
If (trt_box1.Value <> "") Then TRTTRows = .Cells(.Rows.Count, "AA").End(xlUp).Row + 1
.Cells(TRTTRows, "AA").Value = DTPicker1.Value
.Cells(TRTTRows, "AB").Value = trt_box1.Value
.Cells(TRTTRows, "AC").Value = Shift_ComboBox.Value
If TRTTRows > 1 Then
For I = 2 To TRTTRows
If (trt_box(I).Value <> "") Or (Shift_ComboBox.Value <> "") Then ***THIS IS THE LINE THAT IS HIGHLIGHTED
TRTTRows = TRTTRows + 1
.Cells(TRTTRows, "AA").Value = DTPicker1.Value
.Cells(TRTTRows, "AB").Value = trt_box(I).Value
.Cells(TRTTRows, "AC").Value = Shift_ComboBox.Value
End If
Next I
End If
End If
*****the code that adds boxes dynamically in a form*****
Code:
Private Sub btnNextTRTT_Click()'ErrorHandler
Dim LeftAdjust As Long
Dim TopAdjust As Long
'Add the next row of boxes
TRTTRows = TRTTRows + 1
ReDim Preserve trtt_label(TRTTRows)
ReDim Preserve trt_box(TRTTRows)
If TRTTRows < 4 Then
LeftAdjust = 0
TopAdjust = (TRTTRows - 1) * 20
ElseIf TRTTRows < 7 Then
LeftAdjust = 168
TopAdjust = (TRTTRows - 4) * 20
Else
LeftAdjust = 336
TopAdjust = (TRTTRows - 7) * 20
End If
et trtt_label(TRTTRows) = MultiPage2.Pages("Page4").Controls.Add("Forms.Label.1", "trtt_label" & TRTTRows)
trtt_label(TRTTRows).Caption = "Please Select"
trtt_label(TRTTRows).Left = 168 + LeftAdjust
trtt_label(TRTTRows).Top = 198 + TopAdjust
trtt_label(TRTTRows).Width = 72
Set trt_box(TRTTRows) = MultiPage2.Pages("Page4").Controls.Add("Forms.ComboBox.1", "trt_box" & TRTTRows)
trt_box(TRTTRows).Left = 252 + LeftAdjust
trt_box(TRTTRows).Top = 198 + TopAdjust
trt_box(TRTTRows).Width = 72
trt_box(TRTTRows).AddItem "ABC1"
trt_box(TRTTRows).AddItem "ADE2"
trt_box(TRTTRows).AddItem "ADG3"
If TRTTRows > 8 Then
btnNextTRTT.Enabled = False
End If
End Sub