I have two separate IF checks for a list box within a function called ExportFiles. If either check fails (listbox is empty, or no listbox items are selected - which I have another function to check) I want the function to end. Currently I have it written like this, but it seems repetitive and too lengthy. If I combined the criteria into an OR with just one IF, then I couldn't specify the error through two different MsgBoxes. Is there another approach to make this code more concise?
If MYBOX.ListCount = 0 Then
MsgBox "ListBox is empty"
ExportFiles = False
Exit Function
End If
If Not IsBoxSelected(MYBOX) Then
MsgBox "Nothing is selected in ListBox"
ExportFiles = False
Exit Function
End If
Aucun commentaire:
Enregistrer un commentaire