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
 
As I explained before:
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

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You are making reading your code very hard. :(
The idea of the code tags is to preserve the code indentations, which I know you have, but you have somehow managed to post it without those indentations. Perhaps you copied it from the forum post #29 instead of copying it from your vba editor window?
 
Upvote 0
You are making reading your code very hard. :(
The idea of the code tags is to preserve the code indentations, which I know you have, but you have somehow managed to post it without those indentations. Perhaps you copied it from the forum post #29 instead of copying it from your vba editor window?
VBA Code:
Option Explicit

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
' for "call back" the code of line will remain as it is
  If Target.Column = 21 And LCase(Target.Value) = "call back" Then Cells(Target.Row + 1, "D").Select
' for <>"ok" I want to add one more condition And column 21 >0 then Cells(Target.Row, "AA").Select
  If Target.Column = 7 And LCase(Target.Value) <> "ok" Then Cells(Target.Row, "AA").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
Thank you. Please make sure in future every time to put your code inside the code tags. :)

Try this change to see if it does what you want
Rich (BB code):
' for <>"ok" I want to add one more condition And column 21 >0 then Cells(Target.Row, "AA").Select
  If Target.Column = 7 And LCase(Target.Value) <> "ok" Then Cells(Target.Row, "AA").Select
  If Target.Column = 7 And LCase(Target.Value) <> "ok" And Cells(Target.Row, 21) > 0 Then Cells(Target.Row, "AA").Select
 
Upvote 0
Thank you. Please make sure in future every time to put your code inside the code tags. :)

Try this change to see if it does what you want
Rich (BB code):
' for <>"ok" I want to add one more condition And column 21 >0 then Cells(Target.Row, "AA").Select
 If Target.Column = 7 And LCase(Target.Value) <> "ok" Then Cells(Target.Row, "AA").Select

	
	
	
	
	
	


VBA Code:
  If Target.Column = 7 And LCase(Target.Value) <> "ok" And Cells(Target.Row, 21) > 0 Then Cells(Target.Row, "AA").Select
Hi peter
thanks for reply
a little issue is still occurring
to get result from this coding first i have to enter value in column U mean 21 and then I have to come back to column G mean 7 but I think after entering the value in Column 7 as I enter value in column 21 then code should execute ...what you say about it I hope you will understand ... thanks
VBA Code:
Option Explicit

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) <> "ok" And Cells(Target.Row, 21) > 0 Then Cells(Target.Row, "AA").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
I don't know what you want.
You said you wanted to move from column 7 (G) to column 27 (AA) if a value other than "ok" was entered in G and column U was > 0

Do you mean this?
You want to move to column AA if a value > 0 is entered in column U and a value other than "ok" is already in column G?
 
Upvote 0
You want to move to column AA if a value > 0 is entered in column U and a value other than "ok" is already in column G?
Yes.... you understand well
dear peter look
column G comes first and column U comes later right...?
so first I enter a value in Column G and then I will come to Column U
so it is very simple first i enter a value in column G as when I enter >0 value in column U then the code should be executed .... I hope now it will be cleared to you
 
Upvote 0
OK, try
Rich (BB code):
  If Target.Column = 7 And LCase(Target.Value) <> "ok" Then Cells(Target.Row, "AA").Select
  If Target.Column = 7 And LCase(Target.Value) <> "ok" And Cells(Target.Row, 21) > 0 Then Cells(Target.Row, "AA").Select
  If Target.Column = 21 And LCase(Cells(Target.Row, 7).Value) <> "ok" And Target.Value > 0 Then Cells(Target.Row, "AA").Select
 
Upvote 0
OK, try
Rich (BB code):
  If Target.Column = 7 And LCase(Target.Value) <> "ok" Then Cells(Target.Row, "AA").Select
  If Target.Column = 7 And LCase(Target.Value) <> "ok" And Cells(Target.Row, 21) > 0 Then Cells(Target.Row, "AA").Select
  If Target.Column = 21 And LCase(Cells(Target.Row, 7).Value) <> "ok" And Target.Value > 0 Then Cells(Target.Row, "AA").Select
wordless effort.....thanks peter
 
Upvote 0

Forum statistics

Threads
1,216,180
Messages
6,129,352
Members
449,506
Latest member
nomvula

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