Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Worksheet Change event problem

Please excuse the crudity off the change procedure below but it is "just
about" doing what I want it to do but I just cannot get that extra input
need to make it work. At the moment it will enter "No N" in column 14
when I change a value in the relevant area in column K The trouble is
that It will enter "No N" anywhere in the column providing there is
"Grass" in column 13. What I want is the value to change only in the
same row on which the change is made in column K and the other rows to
stay unchanged unless another change is made in K on the relevant row. I
value any help.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K12:K160")) Is Nothing Then
With Target
For n = 12 To 160
If Cells(n, 13) = "Grass" Then
Cells(n, 14).Value = "No N"
Else: Cells(n, 14) = ""
End If
Next n
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Kind regards
Graham Haughs
Turriff
Scotland
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Worksheet Change event problem


try
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K12:K160")) Is Nothing Then

' With Target
'For n = 12 To 160
'If Cells(n, 13) = "Grass" Then

n=target.row
if ucase(target)="GRASS" then
Cells(n, 14).Value = "No N"
Else
Cells(n, 14) = ""
End If

' Next n
' End With
End If
ws_exit:
Application.EnableEvents = True
End Sub


--
Don Guillett
SalesAid Software

"Graham Haughs" wrote in message
...
Please excuse the crudity off the change procedure below but it is "just
about" doing what I want it to do but I just cannot get that extra input
need to make it work. At the moment it will enter "No N" in column 14 when
I change a value in the relevant area in column K The trouble is that It
will enter "No N" anywhere in the column providing there is "Grass" in
column 13. What I want is the value to change only in the same row on
which the change is made in column K and the other rows to stay unchanged
unless another change is made in K on the relevant row. I value any help.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K12:K160")) Is Nothing Then
With Target
For n = 12 To 160
If Cells(n, 13) = "Grass" Then
Cells(n, 14).Value = "No N"
Else: Cells(n, 14) = ""
End If
Next n
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Kind regards
Graham Haughs
Turriff
Scotland



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Worksheet Change event problem

Thanks for that Don but getting no entries of "No N" in column N at all
now. A bit confused with < if ucase(target)="GRASS" then as text
"Grass" is in column N. Appreciate your input however and will persevere
with what you sent.

Graham

Don Guillett wrote:
try
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K12:K160")) Is Nothing Then

' With Target
'For n = 12 To 160
'If Cells(n, 13) = "Grass" Then

n=target.row
if ucase(target)="GRASS" then
Cells(n, 14).Value = "No N"
Else
Cells(n, 14) = ""
End If

' Next n
' End With
End If
ws_exit:
Application.EnableEvents = True
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Worksheet Change event problem

Don, this is a rapidly following on apology for the text below. I see
what you have done now, my slower brain just took a bit of catch up
time. many thanks for your help.

Graham


Graham Haughs wrote:
Thanks for that Don but getting no entries of "No N" in column N at all
now. A bit confused with < if ucase(target)="GRASS" then as text
"Grass" is in column N. Appreciate your input however and will persevere
with what you sent.

Graham

Don Guillett wrote:
try
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K12:K160")) Is Nothing Then

' With Target
'For n = 12 To 160
'If Cells(n, 13) = "Grass" Then

n=target.row
if ucase(target)="GRASS" then
Cells(n, 14).Value = "No N"
Else
Cells(n, 14) = ""
End If

' Next n
' End With
End If
ws_exit:
Application.EnableEvents = True
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Worksheet Change event problem

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K12:K160")) Is Nothing Then
' With Target
'For n = 12 To 160
n = Target.Row
If UCase(Cells(n, 13)) = "GRASS" Then
Cells(n, 14).Value = "No N"
Else: Cells(n, 14) = ""
End If
' Next n
' End With
End If
ws_exit:
Application.EnableEvents = True
End Sub


--
Don Guillett
SalesAid Software

"Graham Haughs" wrote in message
...
Thanks for that Don but getting no entries of "No N" in column N at all
now. A bit confused with < if ucase(target)="GRASS" then as text "Grass"
is in column N. Appreciate your input however and will persevere with what
you sent.

Graham

Don Guillett wrote:
try
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K12:K160")) Is Nothing Then

' With Target
'For n = 12 To 160
'If Cells(n, 13) = "Grass" Then

n=target.row
if ucase(target)="GRASS" then
Cells(n, 14).Value = "No N"
Else
Cells(n, 14) = ""
End If

' Next n
' End With
End If
ws_exit:
Application.EnableEvents = True
End Sub


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
Cell value change to trigger macro (worksheet change event?) Neil Goldwasser Excel Programming 4 January 10th 06 01:55 PM
Problem w/ worksheet change event Steph[_6_] Excel Programming 4 October 19th 05 06:41 PM
Worksheet Change Event Problem tim Excel Programming 9 March 28th 05 08:37 AM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM


All times are GMT +1. The time now is 10:22 PM.

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

About Us

"It's about Microsoft Excel"