Yes, you are right. I prematurely clicked yes for Egun's post, Egun's post
does not work.
How can I test to be sure and item and only 1 item is selected when I click
my "Edit Items" button?
To be clear on what my userform has:
"Remove Items" Command Button
"Edit Item" Command Button
"Add Item" Command Button
"Preview" List Box
Sub cmbRemoveItems_Click()
With lbxPreview
For i = .ListCount To 1 Step -1
If .Selected(i - 1) Then
.RemoveItem (i - 1)
End If
Next i
End With
End Sub
Sub cmbEditItem_Click()
' code to ensure only 1 item was selected before continuing
' edit item
With lbxPreview
.List(.ListIndex, 0) = cboPartNumber
.List(.ListIndex, 1) = cboPartDescription
.List(.ListIndex, 2) = Val(tbxQuantity)
.List(.ListIndex, 3) = Format(Val(tbxUnitPrice), "$ #,##0.00")
.List(.ListIndex, 4) = cboBilling
' check if part is billable
If cboBilling = "Warranty" Then
.List(.ListIndex, 5) = Format(0, "$ #,##0.00")
Else
.List(.ListIndex, 5) = Format(Val(tbxQuantity) *
Val(tbxUnitPrice), "$ #,##0.00")
End If
End With
End Sub
Sub cmbAddItem_Click()
' add new item to listbox
With lbxPreview
.AddItem
.List(.ListCount - 1, 0) = cboPartNumber
.List(.ListCount - 1, 1) = cboPartDescription
.List(.ListCount - 1, 2) = Val(tbxQuantity)
.List(.ListCount - 1, 3) = Format(Val(tbxUnitPrice), "$ #,##0.00")
.List(.ListCount - 1, 4) = cboBilling
' check if part is billable
If cboBilling = "Warranty" Then
.List(.ListCount - 1, 5) = Format(0, "$ #,##0.00")
Else
.List(.ListCount - 1, 5) = Format(Val(tbxQuantity) *
Val(tbxUnitPrice), "$ #,##0.00")
End If
End With
End Sub