Add validation using sheet code
Hi Gareth:
This should give you some ideas:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns("P")) Is Nothing Then
If IsEmpty(Target) Then
With Target.Offset(0, 1).Resize(1, 4).Validation
.Delete
.Add Type:=xlValidateTextLength,
AlertStyle:=xlValidAlertStop, _
Operator:=xlEqual, Formula1:=0
.ErrorMessage = "Please input in column P first!"
.ShowInput = False
.ShowError = True
End With
Else
With Target.Offset(0, 1).Resize(1, 4).Validation
.Delete
'Your regular validation parameters here
End With
End If
End If
End Sub
Regards,
Vasant.
"Gareth" wrote in message
...
At the moment columns P:T all have the same data
validation list applied to them.
Users have been told to start in colum P but this does not
always happen. So I have decided to apply the list only
to column P, Q:T are to be applied with a text lenght
validation (text lenght = 0, and error message telling
them to enter in column P).
This all works fine, what I cannot quite get to work is
the sheet code telling Excel to add the validation list to
column Q when an entry has been made in column P (and so
on until column T has the list)
Hope someone can point me in the right direction.
Gareth
|