Modify code

B

bigmaas

Hi,
I have applied the following code to my worksheet:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("A1:A20"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 1).ClearContents
Else
With .Offset(0, 1)
.NumberFormat = "dd mmm yyyy"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub

The code works but does not quite satisfy my requirements. All the cells in
the range A1:A20 have dropdown boxes with the choice of B,F,J,N. When B or F
is selected the value "Now" sould be entered in the offset cells and if J or
N is selected the offset cells shall be cleared.
Please assist with this problem.
Best regards
 
G

Gary''s Student

Replace:
If IsEmpty(.Value) Then
with:
If IsEmpty(.Value) Or .Value = "J" OR .Value = "N" Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top