Я предполагаю, что lst_Added
является списком.
Так что перед использованием проверьте, выбрано ли что-то или нет.Вы можете сделать это с помощью
If lst_Added.Listindex = -1 Then
Msgbox "Please select something"
Exit Sub
End If
Затем используйте свой код как
If Sheets("Report").Cells(i, "A").Value = lst_Added.Value....
Ваш код можно записать как ( Не проверено )
Private Sub submitmobile_Click()
Dim i As Long, LastRow As Long
Dim lbValue As String
Dim ws As Worksheet
If lst_Added.ListIndex = -1 Then
MsgBox "Please select something"
Exit Sub
End If
'~~> Get value of the selected item in the listbox
lbValue = lst_Added.List(lst_Added.ListIndex)
Set ws = ThisWorkbook.Sheets("Report")
With ws
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If .Cells(i, "A").Value = lbValue Or _
.Cells(i, "A").Value = Val(lbValue) Then
mobileutilize = .Cells(i, "F").Value
mobilehours = .Cells(i, "H").Value
End If
Next
End With
End Sub