I'm using the first row of the listbox to populate column headings and want to unselect it when the user selects it. I can accomplish this fine by clicking a button that sets the listindex = -1 but I can't get it to do this when the user clicks or when the listbox changes. I've tried using a global boolean to disable the change event but no matter what, after the subs run, listindex returns to 0 and the first row is selected. I've also tried setting .selected(0) = false but this also does not work.
Here's the code I currently have
Code
Option Explicit
Public skipchange As Boolean
Private Sub PlateList_Change() ' I've also tried putting this code in the click event for the listbox
Dim x As Integer, c As Integer, strarr() As String, selplatedata As String
If skipchange = True Then
skipchange = False
Exit Sub
end if
If SetupForm.PlateList.ListIndex = -1 Then
Exit Sub
End If
If SetupForm.PlateList.ListIndex = 0 Then
skipchange = True
SetupForm.PlateList.ListIndex = -1
skipchange = False
Exit Sub
End If
End Sub
Display More