ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cursor skip over a cell (https://www.excelbanter.com/excel-programming/341988-cursor-skip-over-cell.html)

mikeburg[_39_]

Cursor skip over a cell
 

Help. Working on some simple sheet VBA code to:

(1) skip over a cell from the cell above using enter, tab, or arrow
and

(2) skip over a cell from the cell below using the up arrow

I have the following code that works from above:

'SECTION TO JUMP FROM CELL F16 TO G 19 (skip F17:G18)
If Target.Address = "$F$17:$G$18" Then Target(3, 2).Select


Can someone help me add the code to skip cells F17:G18 when I up arrow
from the cell below? Thanks, mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=473427


K Dales[_2_]

Cursor skip over a cell
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Skips over range F17:G17 if moved into from directly above or directly below
' static variable used to keep track of where we moved from:
Static CameFrom As String
' Check to see if we moved into the designated range
If Not (Intersect(Target, Range("F17:G18")) Is Nothing) Then
' Now check to see where we came from:
Select Case CameFrom
Case "$F$16", "$G$16"
Range("G19").Select ' if from cells above, move below
Case "$F$19", "$G$19"
Range("F16").Select ' if from cells below, move above
End Select
CameFrom = Selection.Address
Else
CameFrom = Target.Cells(1, 1).Address
End If
' Note how CameFrom is reset toward the end of the sub to
' keep use the new selection as CameFrom next time we move
End Sub

--
- K Dales


"mikeburg" wrote:


Help. Working on some simple sheet VBA code to:

(1) skip over a cell from the cell above using enter, tab, or arrow
and

(2) skip over a cell from the cell below using the up arrow

I have the following code that works from above:

'SECTION TO JUMP FROM CELL F16 TO G 19 (skip F17:G18)
If Target.Address = "$F$17:$G$18" Then Target(3, 2).Select


Can someone help me add the code to skip cells F17:G18 when I up arrow
from the cell below? Thanks, mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=473427



mikeburg[_40_]

Cursor skip over a cell
 

Works great! Thank you. mikebur

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=47342



All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com