I am trying to create a list box that will show a list of customer's and ask the user to select one. Once they select it I want to have the selected customer stored as a variable I can add to a new field that populates an order form with the existing information we have.
My problem is when I select the customer and it keeps adding nothing to my selected field. My codes are as follows.
in the UserForm I have this
My test macro is as follows
So the it all runs without issue but it is not adding anything to the cell A1 any ideas why that would be? Am I missing something.
Also I had to declare my CUSTOMERSELECT variable in the userform to avoid an error saying the variable was not declared not sure why since I hardly ever declare a variable in the user form itself just in the macro that uses the variable.
My problem is when I select the customer and it keeps adding nothing to my selected field. My codes are as follows.
in the UserForm I have this
Code:
Dim CUSTOMERSELECT As String
Option Explicit
Private Sub CommandButton1_Click()
CUSTOMERSELECT = Me.ListBox1.Value
Unload Me
End Sub
Private Sub CommandButton2_Click()
EXISTINGCANCEL = True
Unload Me
End Sub
Private Sub ListBox1_Click()
End Sub
Private Sub UserForm_Initialize()
Dim CUST As Variant
Me.Label1.Caption = "Please select a customer from the list."
With Me.ListBox1
For Each CUST In Worksheets("Customer List").Range("I10:I700")
If CUST <> " " Then .AddItem CUST
Next CUST
End With
End Sub
My test macro is as follows
Code:
Dim CUSTOMERSELECT As String
Dim EXISTINGCANCEL As Boolean
Sub testlist()
EXISTINGCANCEL = False
UserFormCustomerList.Show
If EXISTINGCANCEL Then Exit Sub
Worksheets("sheet1").Activate
Range("A1").Select
ActiveCell.Formula = CUSTOMERSELECT
End Sub
So the it all runs without issue but it is not adding anything to the cell A1 any ideas why that would be? Am I missing something.
Also I had to declare my CUSTOMERSELECT variable in the userform to avoid an error saying the variable was not declared not sure why since I hardly ever declare a variable in the user form itself just in the macro that uses the variable.