By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,650 Members | 1,785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

code enter key action to shift to right on one excel sheet

100+
P: 107
can I use VB to work in microsoft excel to cause the enter button to shift to the right instead of down. I only want one worksheet to have this in.
Trying to get code in Private Sub Worksheet_change(ByValTarget as range) procedure.
No matter what I do - I cause all my excel sheets to go to the right when I hit enter and I only want one worksheet to.
any ideas
thank you
Apr 29 '08 #1
Share this Question
Share on Google+
3 Replies


kadghar
Expert 100+
P: 1,295
can I use VB to work in microsoft excel to cause the enter button to shift to the right instead of down. I only want one worksheet to have this in.
Trying to get code in Private Sub Worksheet_change(ByValTarget as range) procedure.
No matter what I do - I cause all my excel sheets to go to the right when I hit enter and I only want one worksheet to.
any ideas
thank you
only write it inside a single sheet's code, not inside the workbook's or a module's code.

this might help:

Expand|Select|Wrap|Line Numbers
  1. Sub Worksheet_change(ByVal Target as range)
  2.  
  3. target.offset(0,1).select
  4.  
  5. end sub
or

Expand|Select|Wrap|Line Numbers
  1. dim Boo1 as boolean
  2. Sub Worksheet_selectionchange(ByVal Target as range)
  3. if boo1= false then
  4.     boo1=true
  5.     if target.row > 1 then target.offset(-1,1).select
  6.     boo1=false
  7. end if
  8. end sub


for something more complex, you might need to define the GetAsyncKeyState function.

HTH
Apr 29 '08 #2

100+
P: 107
Thanks for solutions- sorry took long to get back-
first solution:
If I input a number and hit enter- it goes to the right.
but if I don't input a number it does nothing. and if I am in cell with number I do not change it does not move either.

second solution:
it moves to the right but I can't even select a cell other than in the first row

any more ideas
Thank you
Apr 30 '08 #3

kadghar
Expert 100+
P: 1,295
Thanks for solutions- sorry took long to get back-
first solution:
If I input a number and hit enter- it goes to the right.
but if I don't input a number it does nothing. and if I am in cell with number I do not change it does not move either.

second solution:
it moves to the right but I can't even select a cell other than in the first row

any more ideas
Thank you
Well, if the second solution does that, its because you didnt define the boolean called Boo1 outside the sub, as a declaration. Or maybe you defined it in someother module, but not as a public variable.

The problem that solution has, is that no matter what, when you select a cell, you'll be selecting the one above and right from it. That's why i put the second suggestion.

With GetAsyncKeyState you can check if the key used to change the selection was the [enter] key, and in that case, run the code.
Apr 30 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.