+ Reply to Thread
Results 1 to 6 of 6

need function or macro to move the cursor to the selected cell.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    need function or macro to move the cursor to the selected cell.

    Hello Team,

    I have the macro added spread sheet where when I have selected one name from the drop down in the A column, the tab automatically move to G column, when we update the G column the tab automatically move to K column. Please let us know how to do that and one more thing that when I select different name in the A column the tab needs to automatically move to D column and when D column is updated the tab needs to be move to J column. Please assist me on how to do that using formula or macros.

    Regards,
    Girish

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: need function or macro to move the cursor to the selected cell.

    Use a change event on the sheet code.

  3. #3
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: need function or macro to move the cursor to the selected cell.

    please explain more on the above change event on the sheet code in brief. Thank you.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: need function or macro to move the cursor to the selected cell.

    Include a sample worksheet and I'll show you how. If you don't attach a spreadsheet we assume you are fairly competent and only need a general answer. Few responders will take the time to create the conditions we think you have so we can answer your question. What's the "one name" and the "different name?"

    Do you mean if I enter a specific name in column A, the code does one thing and I enter another specific name in column A, the code does something else?

    or
    Do you mean if I enter any name in column A, the code does one thing and I enter any other name in the column it does something else?

    How are you matching names with what the code is supposed to be doing?

  5. #5
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: need function or macro to move the cursor to the selected cell.

    hello team,

    actually what I need is when I select Work A in B2 cell from the drop down the cursor has to move automatically to Task 3 (E2 cell) and once Task 3 has been updated the cursor has to move to Task 6 (H2 cell) instead of manually move the cursor using tab or right arrow key

    Note I have applied conditional format in my master sheet where when I select Work A both the Task 3 and Task 6 cell will get highlighted.

    Please let me know if you need further information and assist me at the earliest. Thanks for your help in advance.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,366

    Re: need function or macro to move the cursor to the selected cell.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
       'Do nothing if more than one cell is changed or content deleted
    
       If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
       
       Application.EnableEvents = False
      
       col = Target.Column
       Row = Target.Row
       Parm = Cells(Row, 2)
       
       If col = 2 Then
         Range("C" & Row & ":N" & Row).ClearContents
       End If
       Select Case Parm
       
       Case Is = "Work A"
       
       If col = 2 Then
           Cells(Row, 5).Activate
           Else
           If col = 5 Then
            Cells(Row, 8).Activate
            GoTo exitsub
           Else
            If col <> 8 Then
            Cells(Row, col) = ""
            GoTo exitsub
            End If
           End If
        End If
           
    
       Case Is = "Work B"
       If col = 2 Then
           Cells(Row, 6).Activate
           Else
            If col <> 6 Then
            Cells(Row, col) = ""
            GoTo exitsub
            End If
        End If
    
       Case Is = "Work C"
       
       If col = 2 Then
           Cells(Row, 4).Activate
           Else
           If col = 4 Then
            Cells(Row, 12).Activate
            GoTo exitsub
           Else
            If col <> 12 Then
            Cells(Row, col) = ""
            GoTo exitsub
            End If
            
           End If
        End If
    
       Case Is = "Work D"
       
       If col = 2 Then
           Cells(Row, 14).Activate
           Else
            If col <> 14 Then
                Cells(Row, col) = ""
                GoTo exitsub
            End If
        End If
          
       Case Is = "Work E"
       
       If col = 2 Then
           Cells(Row, 3).Activate
           Else
           If col = 3 Then
            Cells(Row, 13).Activate
            GoTo exitsub
           Else
           If col <> 13 Then
                Cells(Row, col) = ""
                GoTo exitsub
            End If
           End If
        End If
    
       Case Else
    '      Exit Sub
    End Select
    
                'Stop any possible runtime errors and halting code
    
                On Error Resume Next
    exitsub:
    
                    'Turn events back on
    
                    Application.EnableEvents = True
    
                'Allow run time errors again
    
                On Error GoTo 0
       
    
    End Sub
    Try this:

    It clears previous entries if a line has already been entered i.e. is being overwritten

    To insert code, right click on Sheet1, View code: you can then copy and paste into your master file by repeating the "view code" on sheet in master file.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to move cursor when cursor is moved to certain column
    By skylark332 in forum Excel General
    Replies: 3
    Last Post: 12-08-2015, 01:03 PM
  2. [SOLVED] Macro to move visible cells up one row in a selected cell
    By ediman16 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-22-2015, 05:34 AM
  3. [SOLVED] Macro to move any selected cell to a specific column on the same row
    By Jonah Mulski in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-30-2013, 12:23 PM
  4. Macro line to move the cursor
    By aca in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-01-2012, 03:27 PM
  5. Event-Macro to move the cursor
    By ElmerS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2009, 03:09 PM
  6. Macro command to move cursor down
    By s1awt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-04-2007, 09:59 AM
  7. Replies: 1
    Last Post: 08-26-2005, 03:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1