Creating a directional macro

Solved/Closed
Teene12 - Feb 2, 2010 at 03:25 PM
 Teene12 - Feb 12, 2010 at 10:58 AM
Hello,
I am not familiar with writing macros at all. I created a form and I need a macro so that when I input data in a cell the cursor will automatically go to the next required empty cell. So, basically I need the user of the form
to be able to enter data in a cell and when they press enter the cursor will automatically go to the next required cell. Please help.

6 replies

rizvisa1
Posts
4479
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
769
Feb 2, 2010 at 05:37 PM
Oh I am sorry. When you said form, I presumed you meant the excel form. It seem that you are only using sheets and not the forms (excel forms). In this case have you considered using some thing like this

This code you can write in the sheet that you are using

If you press ALT+F11, a vbe will open up
Once it opens, press CTRL + R to open project explorer window (in case it is not open already)
Expand the tree "VBAProkect(...xls) -- Microsoft Excel Objects -- then double click on the sheet where you want that functionality
Paste the code and modify as you need

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False

Add = Target.Address

' here you have to define how you want to move. in this sample,
' if a1 changes, i want to move to c3
' if c3 changes i want to move to d2

Select Case Add
Case "$A1$1"
Range("C3").Select

Case "$C$3"
Range("D2").Select

End Select

Application.EnableEvents = True


End Sub
1
Teene12
Posts
1
Registration date
Monday February 1, 2010
Status
Member
Last seen
February 3, 2010

Feb 3, 2010 at 03:35 PM
Ok, I did exactly what you said above. I copied and pasted the code and changed the cells that apply to my worksheet, but it does not work. What am I doing wrong? This is a foreign language to me, I have no clue. Am I supposed to activate it somehow? I don't have a password to access the EJHTML4E to show you a screen shot, otherwise I would.
0
rizvisa1
Posts
4479
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
769
Feb 2, 2010 at 03:55 PM
This you should be able to do with the tab order. If you look at the properties of the textbox on your form, you will see an tabindex. It goes from 0 onward. You can have index set up the way you want the control to move
0
I'm sorry, I am not understanding what you mean. I created this in Excel, all the info. is created in cells, so I am not sure where to find the textbox properties.
0
rizvisa1
Posts
4479
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
769
Feb 3, 2010 at 03:59 PM
mail it
0

Didn't find the answer you are looking for?

Ask a question
aquarelle
Posts
7104
Registration date
Saturday April 7, 2007
Status
Anonymous
Last seen
May 24, 2022
490
Feb 3, 2010 at 04:06 PM
Hi,

To give an excel file example (without any personal data) you should use a deposit files website like https://authentification.site and after copy/paste the created link into your next answer.

Best regards
0
Thank you for your help, I figured it out. I just had to enable the macro when I closed the file and opened it back up again. it works perfect.
0