0

I'm trying to make a code which after insert/update value in one cell, will go to the next cell like on the picture. Now this code works only one way:

ActiveCell.Offset(1,0).Select ex. from A2 to B2.

What to do to return offset to the cell on the left from B2 to A3 - need loop like on the picture.

Picture

0

1 Answer 1

2

I am not quite sure if I understood what you are looking! I set a range on column A and B until row 10, just for testing.

This code moves to the next cell on the picture whenever you edit the cell and then you press Enter.

Put this code on the sheet module

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngColA As Range: Set rngColA = Range("A2:A10")
    Dim rngColB As Range: Set rngColB = Range("B2:B10")
    
    If Not Intersect(Target, rngColA) Is Nothing Then
        Target.Offset(0, 1).Select
        exit sub
    End If

    If Not Intersect(Target, rngColB) Is Nothing Then
        Target.Offset(1, -1).Select
    End If
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

YES - that is what I need. Thanks a lot @Elio Fernandes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.