E
ExcelMonkey
I have a userform which has two listboxes. Listbox1 lists
all these sheets in my spreadsheet. there is an Add and
Delete button which allows teh user to click on items in
Listbox1 and add them to Listbox2. When I click onto 1
item in Listbox1 and then press Add, the code fails. I
can't figure out why this is failing. It was working
before. I am getting a:
Run Time Error
Type mismatch error
The last line of code that says:
ListBox2.AddItem ListBox1.Value
Has a null value for ListBox1.Value. This usually has the
name of the sheet I have selected. Another thing is that
I cannot remember what cbDuplicates is. Its not a
variable name.
Private Sub AddButton_Click()
If ListBox1.ListIndex = -1 Then Exit Sub
If Not cbDuplicates Then
' See if item already exists
For i = 0 To ListBox2.ListCount - 1
If ListBox1.Value = ListBox2.List(i) Then
Beep
Exit Sub
End If
Next i
End If
ListBox2.AddItem ListBox1.Value
End Sub
all these sheets in my spreadsheet. there is an Add and
Delete button which allows teh user to click on items in
Listbox1 and add them to Listbox2. When I click onto 1
item in Listbox1 and then press Add, the code fails. I
can't figure out why this is failing. It was working
before. I am getting a:
Run Time Error
Type mismatch error
The last line of code that says:
ListBox2.AddItem ListBox1.Value
Has a null value for ListBox1.Value. This usually has the
name of the sheet I have selected. Another thing is that
I cannot remember what cbDuplicates is. Its not a
variable name.
Private Sub AddButton_Click()
If ListBox1.ListIndex = -1 Then Exit Sub
If Not cbDuplicates Then
' See if item already exists
For i = 0 To ListBox2.ListCount - 1
If ListBox1.Value = ListBox2.List(i) Then
Beep
Exit Sub
End If
Next i
End If
ListBox2.AddItem ListBox1.Value
End Sub