Good Morning,I am receiving a type mismatch error I cannot resolve. Any help would be greatly appreciated.
It occurs when it enters a For loop for the last control, when the loop control = 0.
Code below:I even tried recasting as a Variant, but it didn't help.
I have marked the line with an asterisked comment.
<code>
Private Sub EnterButton_Click()
Dim bCancel As Boolean:
bCancel = False
Dim ws As Worksheet:
Set ws = Sheets("Sheet1")
Dim lastrow As Long,i As Long
Dim x As Long
'''''''''''''''''''''''''''' Check for no selections'''''''''''''''''''''''''''
If LBType.ListIndex = -1 Then MsgBox ("You must select a type!")
bCancel = True
LblType.ForeColor = RGB(255, 0, 0)
ElseIf LBNumber.ListIndex = -1 Then
MsgBox ("You must select a number!")
LblNumber.ForeColor = RGB(255, 0, 0)
bCancel = True
ElseIf LBRotation.ListIndex = -1 Then
MsgBox ("You must select a rotation!")
LblRotation.ForeColor = RGB(255, 0, 0)
bCancel = True
ElseIf cmbNew.ListIndex = False Then
MsgBox ("Please select a new status!")
lblNew.ForeColor = RGB(255, 0, 0)
bCancel = TrueEnd IfIf bCancel = True Then
Exit Sub
End If
lastrow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
For i = 0 To LBType.ListCount - 1
If LBType.Selected(i) Then
ws.Range("A" & lastrow).Value = LBType.List(i)
End If
Next i
For i = 0 To LBNumber.ListCount - 1 If LBNumber.Selected(i) Then
ws.Range("B" & lastrow).Value = LBNumber.List(i) End If
Next i
For i = 0 To LBRotation.ListCount - 1
If LBRotation.Selected(i) Then
ws.Range("C" & lastrow).Value = LBRotation.List(i)
End If
Next x
End Sub
</code>
Bookmarks