tcarter963
New Member
- Joined
- Aug 3, 2006
- Messages
- 38
I'm trying to move the active cell to another cell when it reaches a certain point in my spreadsheet. I can get it to work when it reaches the row, but I need it to work when it reaches specific cells e.g. cells(43, 5) and cells(43,9). I think the code might do a better job of explaining.
If I use ActiveCell.Row = 43 It works like I want it to but unfortunatly I have one row that is on row 44 that I need to include. As it is the ActiveCell moves to Cells(11, ActiveCell.Column + 4).Select no matter where it is in the column. I don't understand why it doesn't work just in cells(43, 5) and cells(43,9). I would really appreciate any help.
Code:
Sub MoveTo()
If ActiveCell = Cells(43, 5) Then
Cells(11, ActiveCell.Column + 4).Select
Else
ActiveCell.Offset(1, 0).Select
End If
End Sub
Sub bbb()
Application.OnKey "{ENTER}", "MoveTo"
End Sub
Sub ccc()
Application.OnKey "{ENTER}"
End Sub
Private Sub Worksheet_Activate()
Call bbb
End Sub
Private Sub Worksheet_Deactivate()
Call ccc
End Sub
If I use ActiveCell.Row = 43 It works like I want it to but unfortunatly I have one row that is on row 44 that I need to include. As it is the ActiveCell moves to Cells(11, ActiveCell.Column + 4).Select no matter where it is in the column. I don't understand why it doesn't work just in cells(43, 5) and cells(43,9). I would really appreciate any help.