Moving to cell based on condition of another cell

G

Guest

I'm creating a form and want to set it up so that if a data is entered into a
cell, then the cursor goes directly to a cell elsewhere within the
spreadsheet where additional info needs to be entered. Any ideas?
 
G

Guest

You could use a macro like this: if data is entered into A1 then C3 is
selected.

To use/test this code, right click on worksheet tab, "view Code" and
copy/paste into code area.


Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Cells(3, "C").Select
End If
ws_exit:
Application.EnableEvents = True
End Sub
 
G

Gord Dibben

Sheet event code? You did say "if data is entered".

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$C$2"
Range("C5").Select
Case "$C$5"
Range("E2").Select
Case "$E$2"
Range("E5").Select
End Select
End Sub

This is event code which runs when a value is entered in one of the trigger
cells.

Right-click on the sheet tab and "View Code". copy/paste the code into that
module.

For non-VBA methods of moving from one cell to another in sequence see Bob
Phillips's site.

http://www.xldynamic.com/source/xld.xlFAQ0008.html


Gord Dibben MS Excel MVP
 
G

Guest

Gord,

Thanks - it works great.

Gord Dibben said:
Sheet event code? You did say "if data is entered".

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$C$2"
Range("C5").Select
Case "$C$5"
Range("E2").Select
Case "$E$2"
Range("E5").Select
End Select
End Sub

This is event code which runs when a value is entered in one of the trigger
cells.

Right-click on the sheet tab and "View Code". copy/paste the code into that
module.

For non-VBA methods of moving from one cell to another in sequence see Bob
Phillips's site.

http://www.xldynamic.com/source/xld.xlFAQ0008.html


Gord Dibben MS Excel MVP
 

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