Data Validation - URGENT PLEASE HELP
Posted by Elodie on July 31, 2001 3:45 AM
Could anyone please let me know urgently how you can set data validation for a combo box please. I want to stop the user entering duplicate enteries from the combo box. Or if there is any VBA code that anyone knows to do this that would be great.
Cheers for you help.
Elodie
The VBA code used to set up my combo box is:
Sub AddDropDown(Target As Range)
Dim ddBox As DropDown
Dim vaProducts As Variant
Dim i As Integer
vaProducts = Array(Sheet2.Cells.Range("A1"), Sheet2.Cells.Range("B1"), Sheet2.Cells.Range("C1"), Sheet2.Cells.Range("D1"), Sheet2.Cells.Range("E1"), Sheet2.Cells.Range("F1"), Sheet2.Cells.Range("G1"), Sheet2.Cells.Range("H1"))
With Target
Set ddBox = Sheet3.DropDowns.Add(.Left, .Top, .Width, .Height)
End With
With ddBox
.OnAction = "EnterProdInfo"
For i = LBound(vaProducts) To UBound(vaProducts)
.AddItem vaProducts(i)
Next i
End With
End Sub
Private Sub EnterProdInfo()
Dim vaPrices As Variant
vaPrices = Array("A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1")
With Sheet3.DropDowns(Application.Caller)
.TopLeftCell.Value = .List(.ListIndex)
.TopLeftCell.Offset(0, 2).Value = vaPrices(.ListIndex - Array(0, 1)(1))
.Delete
End With