Move cursor to specific cell on exit

S

SouthAfricanStan

Win XP Office 2003.
I have designed a form on two worksheets.
I require that, on exiting a cell on one sheet, the cursor moves
automatically to a specific cell on the other sheet in the same workbook.
How can I do this?
 
W

Wild Bill

One way: in the worksheet code window for the first cell, enter

Dim OnKeyCell As Boolean
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If OnKeyCell Then
OnKeyCell = False
Application.Goto reference:="bar"
Exit Sub
End If
If Not Intersect(Target, Range("foo")) Is Nothing Then
OnKeyCell = True
End If
End Sub

where bar is a defined name range for the destination cell.
 
D

Don Guillett

IF???? you mean that you want to ENTER data in a cell and have the cursor
move to the same cell in the next sheet, this can be done with a
worksheet_change event. But, selections are almost NEVER necessary or
desirable. Why not just use a macro that enters data for you

sheets("sheet1").range("a1")=1
sheets("sheet2").range("x1")=10
'etc

OR
Sub putvalues()
myarray = Array("sheet4", "sheet6")
For Each sh In myarray
Sheets(sh).Range("k1") = "hi"
Next
End Sub
 
S

SouthAfricanStan

Nope
Data may or may not be entered in a particular (say E40) cell in the first
sheet; then when the 'Enter' key is pressed the cursor must move to a
specific (say B3) cell in the next (only other) sheet...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top