Move Cursor to specific cell according to the text entered in target cell

Diegodigit

New Member
Joined
Nov 2, 2021
Messages
4
Office Version
  1. 365
Hi,

I would like to move the cursor from a cell to a different cell according to the value entered. For example if I enter "yes" in C1 the cursor should move to B3 If I enter "No" the cursor should move to B4.
I need to do this for mutiple cells. So For C2 if I enter "yes", it should move to E5 if I enter "no" the cursor should move to F5 and so on. Thanks for any kind reply!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Welcome to the Board!

If there is a consistent pattern, we could program it to do that automatically.
But I am not seeing any pattern, as you have C1 going to B3 or B4, and C2 going to E5 or F5.

Can you tell us the logic we can use so we can determine where to move if any cell in column C is updated?
 
Upvote 0
Welcome to the Board!

If there is a consistent pattern, we could program it to do that automatically.
But I am not seeing any pattern, as you have C1 going to B3 or B4, and C2 going to E5 or F5.

Can you tell us the logic we can use so we can determine where to move if any cell in column C is updated?
Hi! it si for a phone call script so according to the answer the next question should be chosen. There is no fixed pattern. I found this piece of vba code which works for the first answer but do not know how to do with other answers.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) <> "B5" Then Exit Sub
Application.EnableEvents = False
If Target.Value = "Yes" Then
Range("B6").Select
ElseIf Target.Value = "No" Then
Range("B9").Select
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
Hi! it si for a phone call script so according to the answer the next question should be chosen. There is no fixed pattern. I found this piece of vba code which works for the first answer but do not know how to do with other answers.
If there is no distinct pattern/rule we can follow, you will need to provide us with a rule for each one individually.
You already did that for the first two (updates to C1 and C2). How many more are there?
 
Upvote 0
Well there are quite a few....I was wondering if there was a bunch of instructions I could set with different value depending on the case. Is there any? Thank you!
 
Upvote 0
You would need a separate block for each one, something like this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Select Case Target.Address(False, False)
        
        Case "B5"
            If Target.Value = "Yes" Then
                Range("B6").Select
            ElseIf Target.Value = "No" Then
                Range("B9").Select
            End If

        Case "C1"
            If Target.Value = "Yes" Then
                Range("B3").Select
            ElseIf Target.Value = "No" Then
                Range("B4").Select
            End If

        Case "C2"
            If Target.Value = "Yes" Then
                Range("E5").Select
            ElseIf Target.Value = "No" Then
                Range("F5").Select
            End If
    
    End Select

End Sub
Alternatively, if they are all doing the same thing and checking for "Yes" and "No", and moving to certain cells based on that, it is may be possible to set up some array variables so you only need one block of code to check.
 
Upvote 0
You would need a separate block for each one, something like this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Select Case Target.Address(False, False)
       
        Case "B5"
            If Target.Value = "Yes" Then
                Range("B6").Select
            ElseIf Target.Value = "No" Then
                Range("B9").Select
            End If

        Case "C1"
            If Target.Value = "Yes" Then
                Range("B3").Select
            ElseIf Target.Value = "No" Then
                Range("B4").Select
            End If

        Case "C2"
            If Target.Value = "Yes" Then
                Range("E5").Select
            ElseIf Target.Value = "No" Then
                Range("F5").Select
            End If
   
    End Select

End Sub
Alternatively, if they are all doing the same thing and checking for "Yes" and "No", and moving to certain cells based on that, it is may be possible to set up some array variables so you only need one block of code to check.
HI! I tried this code but it won't work. If i press enter the cursor would just go down one cell. Any idea of how this could work? Thank you
 
Upvote 0
Have you placed this code in the Sheet module of the sheet you want it to run against (it MUST be in the sheet module -- if it is in any other module, it will not run automatically)?

Also, since you original code was temporarily disabling events, if it errored out before turning them back on, events would be disabled and this code would not run automatically.
You can manually run this bit of code to turn them back on:
VBA Code:
Private Sub ReEnableEvents()
    Application.EnableEvents = True
End Sub
and then try again.

If i press enter the cursor would just go down one cell.
Are you actually changing the value of the cell, or just going to it and pressing ENTER?
The code is only activated when a value in the cell is manually changed.

Also note that I just went with the logic you originally had in your code, which is case-sensitive - so it is looking for entries of "Yes" and "No".
Entries like "YES", "yes", "NO", and "no" would NOT trigger the code.
If we wanted to make the code case-insensitive so it would work on any of those entries, then we would need to modify it like this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Select Case Target.Address(False, False)
        
        Case "B5"
            If UCase(Target.Value) = "YES" Then
                Range("B6").Select
            ElseIf UCase(Target.Value) = "NO" Then
                Range("B9").Select
            End If

        Case "C1"
            If UCase(Target.Value) = "YES" Then
                Range("B3").Select
            ElseIf UCase(Target.Value) = "NO" Then
                Range("B4").Select
            End If

        Case "C2"
            If UCase(Target.Value) = "YES" Then
                Range("E5").Select
            ElseIf UCase(Target.Value) = "NO" Then
                Range("F5").Select
            End If
    
    End Select

End Sub
If none of this works, then please provide an example where it is not working, i.e. tell us what cell you are updating with what value, and if you have made any changes to the code, please post the revised code you are using.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top