Cursor Movement

JERRY89
4StarLounger
Posts: 516
Joined: 21 Feb 2016, 02:52

Cursor Movement

Post by JERRY89 »

Hi ,

I have use the macro code below to control the cursor movement when i key in data from column A until I then i press Enter the cursor will directly goes to column A row below but what is my problem is whenever i want to do amendment to the column backwards the Enter function does not works as i reach to column I it will not control the cursor to back to column A row below.

Code: Select all

Private Sub Worksheet_Change(ByVal Target As Range)
' Code goes in the Worksheet specific module
Dim rng As Range
    ' Set Target Range,Range("A1:I3")
    Set rng = Target.Parent.Range("A:I")
    ' Only look at single cell changes
    If Target.Count > 1 Then Exit Sub
    ' Only look at that range
    If Intersect(Target, rng) Is Nothing Then Exit Sub
    ' Action if Condition(s) are met (do your thing here...)
    Cells(Target.Row + 1, "A").Select
End Sub

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cursor Movement

Post by HansV »

I don't understand why you need a macro for this. The default setting for pressing Enter in Excel is to move to the cell below:
S0932.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Cursor Movement

Post by Rudi »

Can you also explain what you mean by: "...whenever i want to do amendment to the column backwards..."?

I understand that you want the active cell to return to column A of the next row (and the code does this successfully), but I don't understand what you are amending?
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

JERRY89
4StarLounger
Posts: 516
Joined: 21 Feb 2016, 02:52

Re: Cursor Movement

Post by JERRY89 »

Hi Mr Rudi,
As for your information column A till I i needed to key in my invoice data and all my movement i using Tab key to move my cursor along the row so for example when i key in Data from column A1 till I1 suddenly when i found out there is a mistake such as in D1 i using the Arrow key to backward to do correction of Data then just using Tab key to key data till the End column I1 then the Macro formula above does not work when I using the Enter key it won't automatically goes to the next row A2.The formula above only work when all data key in from column A1 till I1 without backward then Enter Key will goes to the next row starting point column A.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Cursor Movement

Post by Rudi »

Hi Jerry,

I understand now what you mean by amending backwards, but now that I'm using your macro in a sample workbook, I find that using the TAB key also triggers the macro. In other words, I start to key in a new record and when I type in cell A2 (or B2, C2, ...) and TAB (like you inform), the macro immediately moves to cell A3. So I am not sure if you have some environmental setting that is different to me, but I cannot exit the cell without the macro causing the cell to jump back to the A column. Because of this I cannot advise on any correction as I cannot recreate your issue?
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.