Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Cursor Movement

The following code words fine, as long as Excel is set to move the cursor to
the right after hitting enter. If I enter something however and hit the
cursor up, down, or to the left, the code obviously doesn't work. How do I
rewrite this code so that regardless of whether a user has set Excel to move
right, left, up, or down after enter (or does so manually), it still works?
My intent is that for the activecell in Col K, if what the user enters is
the value in Col I (same row), then verbiage is entered on the same row, in
Col L. If the value is <= Col I (same row), any verbiage on the same row in
Col L is cleared. Thanks for any assistance that can be provided.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("$K$8:$K$65000")) Is Nothing) Then
If Target.Value ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0) = "DELEGATION LEVEL EXCEEDED!"
ActiveCell.Font.ColorIndex = 3
End If
If Target.Value = ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0).ClearContents
End If
If Target.Value < ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0).ClearContents
End If
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Cursor Movement

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("$K$8:$K$65000")) Is Nothing) Then
On Error goto ErrHandler
Application.EnableEvents = False
If Target.Value Target.Offset(0, -4) Then
Target.Offset(0,1) = "DELEGATION LEVEL EXCEEDED!"
Target.Offset(0,1).Font.ColorIndex = 3
End If
If Target.Value = Target.Offset(0, -4) Then
Target.Offset(0, 1).ClearContents
End If
If Target.Value < Target.Offset(0, -4) Then
Target.Offset(0, 1).ClearContents
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Paige" wrote in message
...
The following code words fine, as long as Excel is set to move the cursor

to
the right after hitting enter. If I enter something however and hit the
cursor up, down, or to the left, the code obviously doesn't work. How do

I
rewrite this code so that regardless of whether a user has set Excel to

move
right, left, up, or down after enter (or does so manually), it still

works?
My intent is that for the activecell in Col K, if what the user enters is

the value in Col I (same row), then verbiage is entered on the same row,

in
Col L. If the value is <= Col I (same row), any verbiage on the same row

in
Col L is cleared. Thanks for any assistance that can be provided.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("$K$8:$K$65000")) Is Nothing) Then
If Target.Value ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0) = "DELEGATION LEVEL EXCEEDED!"
ActiveCell.Font.ColorIndex = 3
End If
If Target.Value = ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0).ClearContents
End If
If Target.Value < ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0).ClearContents
End If
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Cursor Movement

Great! Thanks Tom!

"Tom Ogilvy" wrote:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("$K$8:$K$65000")) Is Nothing) Then
On Error goto ErrHandler
Application.EnableEvents = False
If Target.Value Target.Offset(0, -4) Then
Target.Offset(0,1) = "DELEGATION LEVEL EXCEEDED!"
Target.Offset(0,1).Font.ColorIndex = 3
End If
If Target.Value = Target.Offset(0, -4) Then
Target.Offset(0, 1).ClearContents
End If
If Target.Value < Target.Offset(0, -4) Then
Target.Offset(0, 1).ClearContents
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Paige" wrote in message
...
The following code words fine, as long as Excel is set to move the cursor

to
the right after hitting enter. If I enter something however and hit the
cursor up, down, or to the left, the code obviously doesn't work. How do

I
rewrite this code so that regardless of whether a user has set Excel to

move
right, left, up, or down after enter (or does so manually), it still

works?
My intent is that for the activecell in Col K, if what the user enters is

the value in Col I (same row), then verbiage is entered on the same row,

in
Col L. If the value is <= Col I (same row), any verbiage on the same row

in
Col L is cleared. Thanks for any assistance that can be provided.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("$K$8:$K$65000")) Is Nothing) Then
If Target.Value ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0) = "DELEGATION LEVEL EXCEEDED!"
ActiveCell.Font.ColorIndex = 3
End If
If Target.Value = ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0).ClearContents
End If
If Target.Value < ActiveCell.Offset(0, -3) Then
ActiveCell.Offset(0, 0).ClearContents
End If
End If
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
cursor movement jed24 New Users to Excel 3 January 26th 10 06:24 AM
CURSOR MOVEMENT Aligahk06 Excel Discussion (Misc queries) 3 September 9th 09 04:55 PM
Cursor Movement? micah Excel Worksheet Functions 10 October 30th 07 04:18 AM
cursor movement Paulo Couto Excel Discussion (Misc queries) 5 October 25th 07 11:32 PM
Movement of cursor L... Excel Worksheet Functions 4 May 6th 06 03:48 AM


All times are GMT +1. The time now is 03:56 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"