Results 1 to 5 of 5

Thread: Event which fires when moving from one cell to another in Excel

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574

    Event which fires when moving from one cell to another in Excel

    How do I trap the lost focus event of a cell in Excel. In other words, which is the event that is fired when one moves from one cell to a different cell? Is it the Worksheet object's Change event?

  2. #2
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    This example code goes on the sheet's code page . . .

    VB Code:
    1. Dim OldCell As Range
    2.  
    3. Private Sub Worksheet_Activate()
    4.     Set OldCell = Excel.ActiveCell
    5. End Sub
    6. Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    7.     On Error Resume Next
    8.     MsgBox "You just moved from " & OldCell.Address & vbCr & _
    9.            "You are now on " & Target.Address
    10.     On Error GoTo 0
    11.     Set OldCell = Excel.ActiveCell
    12. End Sub
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574
    I wanted to be notified when I was leaving a cell. But I can take a leaf from that. May be it is workable. Thanks.

  4. #4
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    That's what it does! It lets you know when you leave a cell by giving you the address of the cell you just left.

    Did you need to keep them on the same cell?

    Excel can be modified to do just about anything you need.
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574
    No. This will do. Thanks very much.

Posting Permissions

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



Click Here to Expand Forum to Full Width