PC Review


Reply
Thread Tools Rate Thread

Code not working to move cursor down on Enter.

 
 
Mike K
Guest
Posts: n/a
 
      4th Jun 2008
Oh Wise Ones,

I just need the curser to move down when I press enter, only when inside a
set range on a set workbook/worksheet, and move to the right all other
times.

From JLGWhiz-

First I tied this:

Set MyRange = ActiveSheet.Range("J3:L12")
If Intersect(MyRange, Target) Then
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlDown
Else
Application.MoveAfterReturnDirection = xlToRight
End If

Did not do anything, still moved to the right.

Then I tried this from another post:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Set Target = Intersect(Target, Range("J3:L12"))
If Not Target Is Nothing Then
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlToRight
Else
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlDown
End If
End Sub

Did not work either, got an error when it was placed in a module.

Any suggestions?

Thanks,
Mike
 
Reply With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      4th Jun 2008
~Hi Mike,

JLG's code works for me.

This is event code and should be pasted
into the worksheets's code module (not a
standard module and not the workbook's
ThisWorkbook module):

Right-click the worksheet's tab |
Select 'View Code' from the menu
Paste the code
Alt-F11 to return to Excel.




---
Regards.
Norman


"Mike K" <(E-Mail Removed)> wrote in message
news:84804B48-A0FB-4428-81CD-(E-Mail Removed)...
> Oh Wise Ones,
>
> I just need the curser to move down when I press enter, only when inside a
> set range on a set workbook/worksheet, and move to the right all other
> times.
>
> From JLGWhiz-
>
> First I tied this:
>
> Set MyRange = ActiveSheet.Range("J3:L12")
> If Intersect(MyRange, Target) Then
> Application.MoveAfterReturn = True
> Application.MoveAfterReturnDirection = xlDown
> Else
> Application.MoveAfterReturnDirection = xlToRight
> End If
>
> Did not do anything, still moved to the right.
>
> Then I tried this from another post:
>
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> Set Target = Intersect(Target, Range("J3:L12"))
> If Not Target Is Nothing Then
> Application.MoveAfterReturn = True
> Application.MoveAfterReturnDirection = xlToRight
> Else
> Application.MoveAfterReturn = True
> Application.MoveAfterReturnDirection = xlDown
> End If
> End Sub
>
> Did not work either, got an error when it was placed in a module.
>
> Any suggestions?
>
> Thanks,
> Mike


 
Reply With Quote
 
Mike K
Guest
Posts: n/a
 
      4th Jun 2008
Norman,
The first code did not work at all. The second code sort of
worked. It would move one cell to the right after an entry and then move
down, and stayed down, even after I left the range. I had to go into options
to reset it. Plus it behaved like that on the whole sheet. Is there
something that automatically reverts back to moving right when it is outside
the designated range?


I am using Excel 2003 on Windows XP professional.

Mike

"Norman Jones" wrote:

> ~Hi Mike,
>
> JLG's code works for me.
>
> This is event code and should be pasted
> into the worksheets's code module (not a
> standard module and not the workbook's
> ThisWorkbook module):
>
> Right-click the worksheet's tab |
> Select 'View Code' from the menu
> Paste the code
> Alt-F11 to return to Excel.
>
>
>
>
> ---
> Regards.
> Norman
>
>
> "Mike K" <(E-Mail Removed)> wrote in message
> news:84804B48-A0FB-4428-81CD-(E-Mail Removed)...
> > Oh Wise Ones,
> >
> > I just need the curser to move down when I press enter, only when inside a
> > set range on a set workbook/worksheet, and move to the right all other
> > times.
> >
> > From JLGWhiz-
> >
> > First I tied this:
> >
> > Set MyRange = ActiveSheet.Range("J3:L12")
> > If Intersect(MyRange, Target) Then
> > Application.MoveAfterReturn = True
> > Application.MoveAfterReturnDirection = xlDown
> > Else
> > Application.MoveAfterReturnDirection = xlToRight
> > End If
> >
> > Did not do anything, still moved to the right.
> >
> > Then I tried this from another post:
> >
> > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> > Set Target = Intersect(Target, Range("J3:L12"))
> > If Not Target Is Nothing Then
> > Application.MoveAfterReturn = True
> > Application.MoveAfterReturnDirection = xlToRight
> > Else
> > Application.MoveAfterReturn = True
> > Application.MoveAfterReturnDirection = xlDown
> > End If
> > End Sub
> >
> > Did not work either, got an error when it was placed in a module.
> >
> > Any suggestions?
> >
> > Thanks,
> > Mike

>
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      5th Jun 2008
Mike, if you put the second code in the Worksheet module, it should work like
this:

1. If the change occurs inside the designated range, the cursor move to the
right.
2. If the change occurs outside the range, the cursor moves down.
3. Pressing Enter constitutes a change.

I believe this was what you asked for in the original posting. If you want
something different, then specify what you are looking for and someone will
try to help.

"Mike K" wrote:

> Norman,
> The first code did not work at all. The second code sort of
> worked. It would move one cell to the right after an entry and then move
> down, and stayed down, even after I left the range. I had to go into options
> to reset it. Plus it behaved like that on the whole sheet. Is there
> something that automatically reverts back to moving right when it is outside
> the designated range?
>
>
> I am using Excel 2003 on Windows XP professional.
>
> Mike
>
> "Norman Jones" wrote:
>
> > ~Hi Mike,
> >
> > JLG's code works for me.
> >
> > This is event code and should be pasted
> > into the worksheets's code module (not a
> > standard module and not the workbook's
> > ThisWorkbook module):
> >
> > Right-click the worksheet's tab |
> > Select 'View Code' from the menu
> > Paste the code
> > Alt-F11 to return to Excel.
> >
> >
> >
> >
> > ---
> > Regards.
> > Norman
> >
> >
> > "Mike K" <(E-Mail Removed)> wrote in message
> > news:84804B48-A0FB-4428-81CD-(E-Mail Removed)...
> > > Oh Wise Ones,
> > >
> > > I just need the curser to move down when I press enter, only when inside a
> > > set range on a set workbook/worksheet, and move to the right all other
> > > times.
> > >
> > > From JLGWhiz-
> > >
> > > First I tied this:
> > >
> > > Set MyRange = ActiveSheet.Range("J3:L12")
> > > If Intersect(MyRange, Target) Then
> > > Application.MoveAfterReturn = True
> > > Application.MoveAfterReturnDirection = xlDown
> > > Else
> > > Application.MoveAfterReturnDirection = xlToRight
> > > End If
> > >
> > > Did not do anything, still moved to the right.
> > >
> > > Then I tried this from another post:
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> > > Set Target = Intersect(Target, Range("J3:L12"))
> > > If Not Target Is Nothing Then
> > > Application.MoveAfterReturn = True
> > > Application.MoveAfterReturnDirection = xlToRight
> > > Else
> > > Application.MoveAfterReturn = True
> > > Application.MoveAfterReturnDirection = xlDown
> > > End If
> > > End Sub
> > >
> > > Did not work either, got an error when it was placed in a module.
> > >
> > > Any suggestions?
> > >
> > > Thanks,
> > > Mike

> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
When enter key is pressed, cursor does not move to next cell in Ex Blackie Microsoft Excel Misc 2 20th Mar 2009 05:40 AM
set programmatically: cursor move after <enter> =?Utf-8?B?TG9saWs=?= Microsoft Access Form Coding 7 27th May 2008 08:52 PM
When I press enter, the cursor does not move to the next line. =?Utf-8?B?SmVubmll?= Microsoft Word Document Management 1 4th May 2006 10:27 AM
Cursor not to move when pressing the enter key Alex Martinez Microsoft Excel Programming 2 12th May 2005 07:49 PM
Cursor not to move when hitting the enter key Alex Martinez Microsoft Excel Worksheet Functions 1 12th May 2005 05:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:16 AM.