473,511 Members | 15,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

107 New Member
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
3 2300
kadghar
1,295 Recognized Expert Top Contributor
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
buddyr
107 New Member
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
1,295 Recognized Expert Top Contributor
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

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

Similar topics

5
2683
by: Rajiv | last post by:
HI ALL, actually , i m working in a company having large number of employee , i have two userid and password . on id is from admin group(id given to me by technology manager) of the server and...
0
2841
by: AR Hall | last post by:
This code goes through 3 work sheets in the same XL workbook, day, eve and night shift in each sheet their are columns representing production work orders and reject and downtime for each order...
3
25021
by: Mads Petersen | last post by:
I'm stuck in this code. Hope you can and will help me. I launch it from excel. I have made the following code work, but not as i whant. I need the ranges to be working with something like xlDown....
1
13631
by: S. van Beek | last post by:
Dear reader, Is there somebody who can tell me the VBA code for the following action? To import data from an Excel sheet by referring to a cell name in the Excel sheet.
0
1098
by: Narshe | last post by:
I'm using the excel object from office web components in an asp.net webpage. I have 2 major issues. When a user hits enter on a cell, it moves cells. That's fine, 'cause that's how excel...
11
2539
by: Tempo | last post by:
Hello. I am getting the error that is displayed below, and I know exactly why it occurs. I posted some of my program's code below, and if you look at it you will see that the error terminates the...
24
8390
by: MichaelK | last post by:
Who knows how to prevent submitting a form on the press Enter button before all fields on the form are filled up. People just enter the first field hit Enter and it submits the form and doing...
2
3733
by: socialmx | last post by:
Hi dear friends. Can anyone help me? I created a VB form in Excel and a textbox and one command button. When I click the command button the text entered in the textbox will store in the empty cell...
2
1663
by: Sunfire | last post by:
I was wondering if there was a way to hit enter to insert blank lines while in the designer? I tried this but all it seems to want to do is insert code that really shouldn't be there. For example,...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.