Excel query about Lists
wrote in message
oups.com...
Hi,
Can you help me out to find out a solution about the following..
I have 4 columns in my worksheet,each of them is validated with List of
certain range.I have to check the left cell is blank or not,if the
previous cell(row wise) is not blank then the next cell will allow the
list,otherwise thoe cells will not accept any value.For the 3rd
column's cell ,previous 2 cells has to be checked and follows.
How can I implement that?
To do this you'll need some event code in the worksheet module, which you
can access by rightclicking the sheet tab & selecting "View Code" from the
pop-up menu.
Assuming the 4 columns are A to D, try something like:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 5 And Target.Column < 1 And Target < "" Then
x = Target.Column - 1
If WorksheetFunction.CountA(Target.Offset(0, 0 - x).Resize(1, x)) < x Then
y = Target.Address
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
MsgBox x & " entries to the left are required."
Range(y).Select
Else
MsgBox "OK"
End If
End If
End Sub
|