custom dialog box
Posted by kenny on September 28, 2001 7:12 AM
i'm trying to put a custom dialog box into a worksheet. the code for the form is below. i can pull up the listbox, but when i select one of the listed items, i get the following error in VBA:
Run-time error: '1004':
Method 'Range' of object '_Global' failed.
I then click debug, and it highlights the following line:
Range("SelectionLink") = lstSelection.ListIndex + 1
this is my first crack at VBA, and i've been able to troubleshoot all my other errors - except for this one. any ideas?
Private Sub CommandButton1_Click()
'if the listindex of listbox equals -1 ... nothing selected
If lstSelection.ListIndex = -1 Then
MsgBox "No item selected", vbExclamation
Exit Sub
End If
Range("SelectionLink") = lstSelection.ListIndex + 1
Selection.Cells(1) = Worksheets("bob").Range("D1")
Unload Me
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub