View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bhupinder Rayat Bhupinder Rayat is offline
external usenet poster
 
Posts: 64
Default Validation Procedure with a worksheet change event

Hi All,

I am trying to change the validation of one cell based on the value of
another cell.

I have to following code that basically states that if cell "fPeriod" equals
"WEEK", then change the data validation of cell "fPeriodType" to a list
called "lstWeekNums".

Private Sub Worksheet_Change(ByVal Target As Range)

If Range("fPeriod") = "WEEK" Then

Range("fPeriodType").Clear
With Range("fPeriodType").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Range("lstWeekNums")
.IgnoreBlank = True
.InCellDropdown = True
End With

End If
End Sub

I get an "Method 'Range' of object'_Worksheet' failed error.

Can anyone help please?

Thanks,

B/