ok, put this in the sheet that you want to monitor:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("a:a")
If Not Application.Intersect(KeyCells, Target) Is Nothing Then
processCells Application.Intersect(KeyCells, Target)
End If
End Sub
and put this in module 1:
Sub processCells(ByVal Target As Range)
For Each cell In Target.Cells
Select Case cell.Value
Case Is > 0
With Range("B" & Target.Row).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Sheet2!$A$1:$A$5"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End With
Case Is < 0
MsgBox "Process negative number"
'do nothing
Case Is = 0
MsgBox "Process zero"
Case Else
MsgBox "Case Else"
End Select
Next cell
End Sub
also make sheet2 and put in A1 to A5 "1", "2", "3", "4", "5". That is what the validation list references.
ill upload the workbook too just in case you need it.
Bookmarks