A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

move to the right after hitting enter using macros



 
 
Thread Tools Display Modes
  #1  
Old November 18th, 2009, 06:26 PM posted to microsoft.public.excel.misc
Santa Fe Al
external usenet poster
 
Posts: 1
Default move to the right after hitting enter using macros

Hi All,

I am attempting to cause movement 4 cells to the right of present location
after I enter data and press enter. I had thought a Macro would do this, but
I can't tie a Macro to a cell and a separate button always takes me to the
original cell. How can I make the movement go right four cells and wait for
input after hitting enter in the previous cell?

Thanks, Al
  #2  
Old November 18th, 2009, 07:23 PM posted to microsoft.public.excel.misc
Gary''s Student
external usenet poster
 
Posts: 7,584
Default move to the right after hitting enter using macros

This example is coded for cell B9, but it can be modified for any set of
cells. Enter the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
Set r = Range("B9")
If Intersect(Target, r) Is Nothing Then Exit Sub
Range("F9").Select
End Sub

Once the macro has been installed, entering data in B9 will cause you to
jump to F9.


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200908


"Santa Fe Al" wrote:

Hi All,

I am attempting to cause movement 4 cells to the right of present location
after I enter data and press enter. I had thought a Macro would do this, but
I can't tie a Macro to a cell and a separate button always takes me to the
original cell. How can I make the movement go right four cells and wait for
input after hitting enter in the previous cell?

Thanks, Al

  #3  
Old November 18th, 2009, 07:45 PM posted to microsoft.public.excel.misc
Gord Dibben
external usenet poster
 
Posts: 20,252
Default move to the right after hitting enter using macros

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo endit
Application.EnableEvents = False
Target.Offset(0, 4).Select
endit:
Application.EnableEvents = True
End Sub

This sheet event code. Right-click the sheet tab and "View Code"

Copy/paste into that module.

Alt + q to return to Excel.


Gord Dibben MS Excel MVP

On Wed, 18 Nov 2009 10:26:01 -0800, Santa Fe Al Santa Fe
wrote:

Hi All,

I am attempting to cause movement 4 cells to the right of present location
after I enter data and press enter. I had thought a Macro would do this, but
I can't tie a Macro to a cell and a separate button always takes me to the
original cell. How can I make the movement go right four cells and wait for
input after hitting enter in the previous cell?

Thanks, Al


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:21 PM.


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