#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Modify code

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Modify code

Replace:
If IsEmpty(.Value) Then
with:
If IsEmpty(.Value) Or .Value = "J" OR .Value = "N" Then
--
Gary''s Student - gsnu201001


"bigmaas" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Modify code

Perfect - many thanks

"Gary''s Student" wrote:

Replace:
If IsEmpty(.Value) Then
with:
If IsEmpty(.Value) Or .Value = "J" OR .Value = "N" Then
--
Gary''s Student - gsnu201001


"bigmaas" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify Excel (2003) code for Network environment JMay Setting up and Configuration of Excel 1 March 9th 09 01:05 PM
modify a line code TUNGANA KURMA RAJU Excel Discussion (Misc queries) 6 June 3rd 08 12:31 PM
Modify Code Richard Excel Worksheet Functions 0 March 13th 08 08:19 PM
How to modify the code for different type of input? Eric Excel Worksheet Functions 1 September 1st 07 03:58 PM
How to modify the code for different type of input? Eric Excel Discussion (Misc queries) 2 September 1st 07 12:30 AM


All times are GMT +1. The time now is 12:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"