Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Application OnKey (XP)

    Is it possible to use Application.OnKey "{ESC}" without referencing any procedure? I could not get oit to work.

    Normally the line of code would read something similar to: Application.OnKey "{ESC}", "Your Procedure Here". I would like to just have the Escape Key depressed as part of my code copies cells and pastes them to another area but leaves a visual reference to those cells copied.

    Perhaps there is another way of removing that reference to the copied cells.

    Thanks,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Application OnKey (XP)

    Use

    Application.CutCopyMode = False

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application OnKey (XP)

    Hans,

    I have already tried that suggestion and get the same results. Here is an example of my code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ocell As Range
    If Not Intersect(Target, Range("E:E")) Is Nothing Then
    For Each ocell In Intersect(Target, Range("E:E")).Cells
    If ocell > 0 Then
    Application.CutCopyMode = False
    Range("Defined_Range").Copy
    ocell.Offset(0, 7).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    ocell.Offset(0, 7).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    ocell.Select
    End If
    Next ocell
    End If
    End Sub


    Thanks,
    John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Application OnKey (XP)

    You must set CutCopyCell to False at the end of the procedure, not BEFORE copying and pasting! <img src=/S/groan.gif border=0 alt=groan width=16 height=15>

  5. #5
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application OnKey (XP)

    Hans,

    After moving it to the end, it worked.

    Thanks,
    John

Posting Permissions

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