Hi all. How to bypass a control object (e.g. ListBox) to another sub/function?
For example, what I try here below gives Type Mismatch error when bypassing ListBox1 to SetSelectedListBox sub.
TIA
For example, what I try here below gives Type Mismatch error when bypassing ListBox1 to SetSelectedListBox sub.
VBA Code:
'Select All ListBox1
Private Sub CommandButton3_Click()
SetSelectedListBox ListBox1, True
End Sub
'Clear All ListBox2
Private Sub CommandButton4_Click()
SetSelectedListBox ListBox1, False
End Sub
'Select All ListBox2
Private Sub CommandButton5_Click()
SetSelectedListBox ListBox2, True
End Sub
'Clear All ListBox2
Private Sub CommandButton6_Click()
SetSelectedListBox ListBox2, False
End Sub
Private Sub SetSelectedListBox(inListBox As ListBox, IsSelected As Boolean)
Dim i As Long
For i = 0 To inListBox.ListCount - 1
inListBox.Selected(i) = IsSelected
Next i
End Sub
TIA