Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go To A Particular Cell After Inputting Data In Another Cell And Hitting Enter Options

Tags:

excel

vba

I have a Excel sheet and I'm inputting data in A2, B2 and C2; after I hit enter I want the cursor select the next line so I can input information on A3, B3 and C3 and so on

I found this information

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Range("C2").Value <> "" Then
Range("A3").Select
End If
End Sub

But it only works one time, how can I repeat this process over and over

Thanks for your help.....

like image 521
user2270747 Avatar asked Apr 11 '13 15:04

user2270747


People also ask

How do you jump to a specific cell in Excel?

Press F5 or CTRL+G to launch the Go To dialog. In the Go to list, click the name of the cell or range that you want to select, or type the cell reference in the Reference box, then press OK.

How do you hit Enter in an Excel cell without going to next?

To start a new line of text or add spacing between lines or paragraphs of text in a worksheet cell, press Alt+Enter to insert a line break.


1 Answers

Another way.

  1. If you type anywhere in Col A, the selection will move to Col B.
  2. If you type anywhere in Col B, the selection will move to Col C.
  3. If you type anywhere in Col C, the selection will move back to Col A (Next Line).

Code: This goes in the relevant sheet code area.

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo Whoa

    Application.EnableEvents = False

    If Not Target.Cells.CountLarge > 1 Then
        If Not Intersect(Target, Columns(1)) Is Nothing Then
            Target.Offset(, 1).Select
        ElseIf Not Intersect(Target, Columns(2)) Is Nothing Then
            Target.Offset(, 1).Select
        ElseIf Not Intersect(Target, Columns(3)) Is Nothing Then
            Target.Offset(1, -2).Select
        End If
    End If
Letscontinue:
    Application.EnableEvents = True
    Exit Sub
Whoa:
    MsgBox Err.Description
    Resume Letscontinue
End Sub

ScreenShot

enter image description here

like image 141
Siddharth Rout Avatar answered Sep 21 '22 23:09

Siddharth Rout