+ Reply to Thread
Results 1 to 4 of 4

Cell cursor in Excel to move or select active cell.

Hybrid View

  1. #1
    Registered User
    Join Date
    02-07-2016
    Location
    Dammam
    MS-Off Ver
    2010
    Posts
    34

    Cell cursor in Excel to move or select active cell.

    Hai,

    i have code to collect data from one area to another area. it contains huge data and by the below code it sorted to display in new area
    based on date and number value.

    it copies all data and fill in one area automatically, however the cursor in excel remains in same place while the data being copied and sorted.

    I need cell cursor to move to cell every time, i mean active cell, where the data is pasted.

    Please help.

    Regards,
    ebincharles P


    Option Explicit
    
    Sub OTExtract_Click()
    'End Sub
    'Sub Extract()
    Dim X1 As Integer
    Dim X2 As Integer
    Dim X3 As Integer
    
    Dim X4 As Integer
    Dim na1 As String
    Dim na2 As String
    
    Dim date1 As String
    Dim date2 As String
    
    Dim thod As String
    
    For X1 = 9 To 100
    
    na2 = Me.Cells(X1, 27)
    
    For X2 = 28 To 36
    'row number where all heading lies
    date2 = Me.Cells(8, X2)
    
    For X4 = 9 To 8993 '13874
    
    
    date1 = Me.Cells(X4, 1)
    na1 = Me.Cells(X4, 3)
    
    'MsgBox (" -0- " & na1 & " -1-  " & na2 & " -2-  " & date1 & " -3- " & date2)
    If na2 = na1 And date2 = date1 And Me.Cells(X1, X2) = "" Then
    Me.Cells(X1, X2) = Me.Cells(X4, 37)
    
    ElseIf na2 = na1 And date2 = date1 And Me.Cells(X1, X2) <> "" Then
    Me.Cells(X1, X2) = Me.Cells(X1, X2) & "/" & Me.Cells(X4, 37)
    
    
    End If
    
    Next
    Next '
    Next
    
    End Sub
    Attached Files Attached Files
    Last edited by ebincharles; 09-24-2017 at 08:50 AM. Reason: attachments

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,302

    Re: Cell cursor in Excel to move or select active cell.

    Hi,

    This will put the cursor on each cell that is changed:
    Me.Cells(X1, X2).Select

    Put the above line before or after your "Me.Cells(X1, X2)..." lines in your code.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    02-07-2016
    Location
    Dammam
    MS-Off Ver
    2010
    Posts
    34

    Re: Cell cursor in Excel to move or select active cell.

    Thank you very much for your help.

    However the cursor goes to all the cells. I need to move to cell where the data is been pasted.

    pretty confusing...

  4. #4
    Registered User
    Join Date
    02-07-2016
    Location
    Dammam
    MS-Off Ver
    2010
    Posts
    34

    Re: Cell cursor in Excel to move or select active cell.

    Thank you very much Guru Marvin.. I did it.

    Copy to clipboard
    Option Explicit
    
    Sub OTExtract_Click()
    'End Sub
    'Sub Extract()
    Dim X1 As Integer
    Dim X2 As Integer
    Dim X3 As Integer
    
    Dim X4 As Integer
    Dim na1 As String
    Dim na2 As String
    
    Dim date1 As String
    Dim date2 As String
    
    Dim thod As String
    
    For X1 = 9 To 100
    
    na2 = Me.Cells(X1, 27)
    
    For X2 = 28 To 36
    'row number where all heading lies
    date2 = Me.Cells(8, X2)
    
    For X4 = 9 To 8993 '13874
    
    
    date1 = Me.Cells(X4, 1)
    na1 = Me.Cells(X4, 3)
    
    'MsgBox (" -0- " & na1 & " -1-  " & na2 & " -2-  " & date1 & " -3- " & date2)
    If na2 = na1 And date2 = date1 And Me.Cells(X1, X2) = "" Then
    Me.Cells(X1, X2) = Me.Cells(X4, 37)
    
    Me.Cells(X1, X2).Select ''Here i placed your code 
    
    ElseIf na2 = na1 And date2 = date1 And Me.Cells(X1, X2) <> "" Then
    Me.Cells(X1, X2) = Me.Cells(X1, X2) & "/" & Me.Cells(X4, 37)
    
    
    End If
    
    Next
    Next '
    Next
    
    End Sub

+ 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] Excel VBA code required to move cursor to a sheet and cell as specified in cell A1
    By Smudge72 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2016, 05:47 PM
  2. [SOLVED] Excel:: Move Cursor to the end of an already populated cell
    By lss-bku in forum Excel General
    Replies: 3
    Last Post: 08-24-2012, 06:12 PM
  3. Replies: 1
    Last Post: 06-16-2008, 09:21 AM
  4. [SOLVED] in excel - arrow keys won't work & cursor will not select a cell
    By jimmo in forum Excel General
    Replies: 2
    Last Post: 08-18-2006, 01:40 PM
  5. Replies: 2
    Last Post: 05-28-2006, 09:45 PM
  6. Replies: 1
    Last Post: 08-26-2005, 03:05 PM
  7. [SOLVED] Cursor keys move active cell or scroll screen, how do I select whi
    By Rob Croft in forum Excel General
    Replies: 1
    Last Post: 06-18-2005, 07: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