Option Explicit
Private Sub UserForm_Initialize()
Dim DefinedNames As Name
For Each DefinedNames In ThisWorkbook.Names
ComboBox1.AddItem DefinedNames.Name
Next DefinedNames
End Sub
Private Sub CommandButton1_Click()
Dim Target As Range
Dim a As Variant
If UserForm1.Controls("ComboBox" & "1").Value = "" Or _
UserForm1.Controls("TextBox" & "1").Value = "" Or _
UserForm1.Controls("Textbox" & "2").Value = "" Then
MsgBox "Missing fields!", , "Error message"
Exit Sub
End If
a = TextBox1 & ":" & TextBox2
Set Target = ActiveSheet.Range(a)
With Target
.ClearContents
With .Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Formula1:="=" & ComboBox1
End With
End With
Unload Me
End Sub
Private Sub CommandButton2_Click()
Unload Me
Application.ScreenUpdating = False
End Sub