Hello,
I have the following code in a standard module:
Sub OpenCName()
ChooseCName.Show
End Sub
The userform code is as follows:
Private Sub CommandButton1_Click()
Selection.Value = ListBox1.Value
Unload Me
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim rRng As Range, r As Range, rSortCr As String
Set rRng = Sheets("LiveCustomers").Range("Table1[Name]")
rSortCr = UCase(ActiveCell.Value)
For Each r In rRng
If InStr(UCase(r), rSortCr) Then Me.ListBox1.AddItem r.Value
Next r
If Me.ListBox1.ListCount = 1 Then
Me.ListBox1.ListIndex = 0
Selection.Value = Me.ListBox1.Value
Unload Me
End If
End Sub
However I am getting a runtime error 1004 which says application-defined or object-defined error.
Can anyone help please?
Bookmarks