Create a Macro to jump to next cell

P

Programming Cells

How Do I create a Macro that will allow me to jump to the next Cell Row 1 no
matter where my current position is?
 
J

John Michl

Are you trying to move your cursor to the left after data entry? If
so, a macro is not needed. Change your options settings. Depending on
your version of Excel it is something like:

Tools | Options | Edit | Move Selection after Enter (right)

If that is not what you are trying to do, add a little more detail
about your application.

- John
 
P

Programming Cells

No. I have a worksheet that contains some visual basic code that says when
you reach row 11 in any given cell please jump to the next cell to the
(right) row 1.

Now I would like to be able to force my position to the next cell (right)
row 1 evan if I don't reach row 11. I thought I could do that with a Macro
like Cntl J.
 
M

Markos Mellos

ok, Programming Cells if I understood correctly what you are trying to
achieve the following should work.

Sub MoveTo()
Dim CurRow, CurCol
CurRow = ActiveCell.Row
CurCol = ActiveCell.Column

If CurRow >= 11 Then
Cells(1, CurCol + 1).Select
End If
End Sub

You MUST include the following to the sheet you are working so that your
cell position is checked.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MoveTo
End Sub

By changing the ">=11" part of the MoveTo sub you can define the desired row
number after which the cursor should move to row 1 of the next column.
 
J

John Michl

I understood the request a little differently than Markos. If you want
to create a hot-key so that when pressed, no matter the location, you
got to the top of the next column, the following should work. After
creating the code in VB, assign a hot-key via the Tools | Macro
windows.

Sub GoTop()
Cells(1, ActiveCell.Column + 1).Select
End Sub

- John
 
P

Programming Cells

So that I understand correctly:

My worksheet code looks like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Row = 11 Then

Target.Offset(1 - Target.Row, 1).Select

End If

End Sub

Sub GoTop()
Cells(1, ActiveCell.Column + 1).Select
End Sub


My Macro looks like this:

Sub Macro1()
'
' Macro1 Macro
' Jump to the next cell row 1
'
' Keyboard Shortcut: Ctrl+y
'
End Sub
 
M

Markos Mellos

Programming Cells, John seems to have undestood better your need.
The Sub GoTop() is all you need. Then go to Tools / Macro / Macros / GoTop
and
in the options define the desired shortcut key.
 
Top