{quote}{login=Hugo}{date=23.11.2011 11:13}{thema=}{post}Чуть усовершенствовал - теперь не будет ошибки, если нет совпадений (будет красить красным введённый параметр):
Sub UniqInValidation(x As Variant, y As Variant)
Dim i&
With CreateObject("Scripting.Dictionary")
For i = 1 To UBound(x)
If x(i, 1) = y.Value Then .Item(x(i, 2)) = 1
Next
If .Count > 0 Then
Dim b()
b = .Keys
[e2].Font.Color = vbNormal
[e5].Validation.Delete
[e5].Validation.Add Type:=xlValidateList, Formula1:=Join(b, ",")
[e5].Value = b(0)
Else
[e2].Font.Color = vbRed
End If
End With
End Sub{/post}{/quote}
спасибо!
Sub UniqInValidation(x As Variant, y As Variant)
Dim i&
With CreateObject("Scripting.Dictionary")
For i = 1 To UBound(x)
If x(i, 1) = y.Value Then .Item(x(i, 2)) = 1
Next
If .Count > 0 Then
Dim b()
b = .Keys
[e2].Font.Color = vbNormal
[e5].Validation.Delete
[e5].Validation.Add Type:=xlValidateList, Formula1:=Join(b, ",")
[e5].Value = b(0)
Else
[e2].Font.Color = vbRed
End If
End With
End Sub{/post}{/quote}
спасибо!