When a user enters a value in A6:A22 VBA checks if it contains a number.
If it does it makes the whole value upcase and thats it.
However if a number is not present it checks the value against a list of valid option.
If the value matches an item in the list it makes it upcase and thats it.
However if it does not match any item in the list it displays a userform with a combobox with the list of allowed values.
I am having trouble returning this value to excel.
The macro call happens on worksheet change
However I cannot refer to "Target" from the user form.
Writing to activecell doesn't work as its just changed.
How can I record the address of target and use it again from the user form>?
If it does it makes the whole value upcase and thats it.
However if a number is not present it checks the value against a list of valid option.
If the value matches an item in the list it makes it upcase and thats it.
However if it does not match any item in the list it displays a userform with a combobox with the list of allowed values.
I am having trouble returning this value to excel.
The macro call happens on worksheet change
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
However I cannot refer to "Target" from the user form.
Writing to activecell doesn't work as its just changed.
How can I record the address of target and use it again from the user form>?
Code:
ca = True
If Target.Cells.Count = 1 Then
If Target.Value <> "" Then
If Not HasNumber(Target.Value) Then
If blnExists(Target.Value, Sheets("timesheet").Range("F30:F37")) = False Then
For Each item In Sheets("Timesheet").Range("F30:F37")
UserForm1.ComboBox1.AddItem item.Value
Next item
UserForm1.Show
End If
End If
End If
End If
Code:
Private Sub CommandButton1_Click()
Application.EnableEvents = False
Target.Value = UCase(UserForm1.ComboBox1.Value)
Application.EnableEvents = True
UserForm1.Hide
End Sub
Private Sub CommandButton2_Click()
Application.EnableEvents = False
Target.Value = ""
Application.EnableEvents = True
UserForm1.Hide
End Sub