How to Move mouse cursor to specific next cell/Column based on a cell Value

azad092

Board Regular
Joined
Dec 31, 2019
Messages
198
Office Version
  1. 2007
Platform
  1. Windows
Hi
good morning all members
I want that when I enter a specific word in a cell the mouse cursor should be move to next specific cell or column that i want
for example if I enter the word "Call Back" in cell G2 the mouse cursor should move to the B3 of next row similarly if i enter the word "Ok" in G2 then the mouse cursor should move to the O2
how it can possible please guide me
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
VBA Code:
'Code For Proper Function

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String

On Error GoTo Exitsub

If Not Intersect(Target, Range("E:E,L:L,V:V,AH:AH,AI:AI,AJ:AJ,AX:AX")) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = WorksheetFunction.Proper(Target.Value)
End If

Application.EnableEvents = True
If Target.Column = 63 Or Target.Column = 70 Then
  If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
  Else: If Target.Value = "" Then GoTo Exitsub Else
    Application.EnableEvents = False
    Newvalue = Target.Value
    Application.Undo
    Oldvalue = Target.Value
      If Oldvalue = "" Then
        Target.Value = Newvalue
      Else
        If InStr(1, Oldvalue, Newvalue) = 0 Then
            Target.Value = Oldvalue & ", " & Newvalue
      Else:
        Target.Value = Oldvalue
                
      End If
    End If
  End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
' code for mouse corsur movement
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.CountLarge > 1 Or Target.Row = 1 Then Exit Sub
  If Target.Column = 21 And LCase(Target.Value) = "call back" Then Cells(Target.Row + 1, "D").Select
  If Target.Column = 7 And LCase(Target.Value) <> "fire case" Then Cells(Target.Row, "L").Select
End Sub
 
Upvote 0
VBA Code:
'Code For Proper Function

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String

On Error GoTo Exitsub

If Not Intersect(Target, Range("E:E,L:L,V:V,AH:AH,AI:AI,AJ:AJ,AX:AX")) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = WorksheetFunction.Proper(Target.Value)
End If

Application.EnableEvents = True
If Target.Column = 63 Or Target.Column = 70 Then
  If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
  Else: If Target.Value = "" Then GoTo Exitsub Else
    Application.EnableEvents = False
    Newvalue = Target.Value
    Application.Undo
    Oldvalue = Target.Value
      If Oldvalue = "" Then
        Target.Value = Newvalue
      Else
        If InStr(1, Oldvalue, Newvalue) = 0 Then
            Target.Value = Oldvalue & ", " & Newvalue
      Else:
        Target.Value = Oldvalue
               
      End If
    End If
  End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
' code for mouse corsur movement
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.CountLarge > 1 Or Target.Row = 1 Then Exit Sub
  If Target.Column = 21 And LCase(Target.Value) = "call back" Then Cells(Target.Row + 1, "D").Select
  If Target.Column = 7 And LCase(Target.Value) <> "fire case" Then Cells(Target.Row, "L").Select
End Sub
when I apply this code an error occurred that you can see in image
code snap.jpeg
 
Upvote 0
Thank you for the indented code! ;)

You can only have one Worksheet_Change code per sheet. The codes need to be combined into one. See if this does what you want.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String

  If Target.CountLarge > 1 Or Target.Row = 1 Then Exit Sub
  If Target.Column = 21 And LCase(Target.Value) = "call back" Then Cells(Target.Row + 1, "D").Select
  If Target.Column = 7 And LCase(Target.Value) <> "fire case" Then Cells(Target.Row, "L").Select

On Error GoTo Exitsub

If Not Intersect(Target, Range("E:E,L:L,V:V,AH:AH,AI:AI,AJ:AJ,AX:AX")) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = WorksheetFunction.Proper(Target.Value)
End If

Application.EnableEvents = True
If Target.Column = 63 Or Target.Column = 70 Then
  If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
  Else: If Target.Value = "" Then GoTo Exitsub Else
    Application.EnableEvents = False
    Newvalue = Target.Value
    Application.Undo
    Oldvalue = Target.Value
      If Oldvalue = "" Then
        Target.Value = Newvalue
      Else
        If InStr(1, Oldvalue, Newvalue) = 0 Then
            Target.Value = Oldvalue & ", " & Newvalue
      Else:
        Target.Value = Oldvalue
                
      End If
    End If
  End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
 
Upvote 0
Thanks God......
we have done it
thanks dear peter your help is more charming
 
Upvote 0
You're welcome. :)
hi
peter good morning and have a nice day
I have a question about the yesterday discussion. If I want to make two conditions in one statement then what I have to do
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String

If Target.CountLarge > 1 Or Target.Row = 1 Then Exit Sub
If Target.Column = 21 And LCase(Target.Value) = "call back" Then Cells(Target.Row + 1, "D").Select ' this statement will remain as it is
If Target.Column = 7 And LCase(Target.Value) <> "OK" Then Cells(Target.Row, "AA").Select ' in this line I want to add one more condition And Target.Column 21 >0 then execute the result

On Error GoTo Exitsub

If Not Intersect(Target, Range("E:E,L:L,V:V,AH:AH,AI:AI,AJ:AJ,AX:AX")) Is Nothing Then
Application.EnableEvents = False
Target.Value = WorksheetFunction.Proper(Target.Value)
End If

Application.EnableEvents = True
If Target.Column = 63 Or Target.Column = 70 Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & ", " & Newvalue
Else:
Target.Value = Oldvalue

End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
 
Upvote 0
Can you please put your code in code tags?
 
Upvote 0
hi
peter good morning and have a nice day
I have a question about the yesterday discussion. If I want to make two conditions in one statement then what I have to do
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String

If Target.CountLarge > 1 Or Target.Row = 1 Then Exit Sub
If Target.Column = 21 And LCase(Target.Value) = "call back" Then Cells(Target.Row + 1, "D").Select ' this statement will remain as it is
If Target.Column = 7 And LCase(Target.Value) <> "OK" Then Cells(Target.Row, "AA").Select ' in this line I want to add one more condition And Target.Column 21 >0 then execute the result

On Error GoTo Exitsub

If Not Intersect(Target, Range("E:E,L:L,V:V,AH:AH,AI:AI,AJ:AJ,AX:AX")) Is Nothing Then
Application.EnableEvents = False
Target.Value = WorksheetFunction.Proper(Target.Value)
End If

Application.EnableEvents = True
If Target.Column = 63 Or Target.Column = 70 Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & ", " & Newvalue
Else:
Target.Value = Oldvalue

End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String

If Target.CountLarge > 1 Or Target.Row = 1 Then Exit Sub
If Target.Column = 21 And LCase(Target.Value) = "call back" Then Cells(Target.Row + 1, "D").Select ' this statement will remain as it is
If Target.Column = 7 And LCase(Target.Value) <> "OK" Then Cells(Target.Row, "AA").Select ' in this line I want to add one more condition And Target.Column 21 >0 then execute the result

On Error GoTo Exitsub

If Not Intersect(Target, Range("E:E,L:L,V:V,AH:AH,AI:AI,AJ:AJ,AX:AX")) Is Nothing Then
Application.EnableEvents = False
Target.Value = WorksheetFunction.Proper(Target.Value)
End If

Application.EnableEvents = True
If Target.Column = 63 Or Target.Column = 70 Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & ", " & Newvalue
Else:
Target.Value = Oldvalue

End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,225
Messages
6,129,599
Members
449,520
Latest member
TBFrieds

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