Lots of macros kill the clipboard.
If you toss in enough message boxes/debug.prints, you can see where it's
happening:
Option Explicit
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
' Set directions for cursor movement
On Error Resume Next
MsgBox Application.CutCopyMode & " A"
If Intersect(Target, Range("rosterBlockHd")) Is Nothing Then
MsgBox Application.CutCopyMode & " B"
If Sh.Name < "Roster - Diary Of Duty" Then Exit Sub
If Target.Column = 1 Then
MsgBox Application.CutCopyMode & " c"
Application.MoveAfterReturnDirection = xlDown
MsgBox Application.CutCopyMode & " D"
Else
MsgBox Application.CutCopyMode & " E"
Application.MoveAfterReturnDirection = xlToRight
MsgBox Application.CutCopyMode & " F"
End If
Else
MsgBox Application.CutCopyMode & " G"
MsgBox "Sorry, can't select Header Block cells"
MsgBox Application.CutCopyMode & " H"
Cells(6, Target.Column).Select
MsgBox Application.CutCopyMode & " i"
Exit Sub
End If
End Sub
A cutcopymode of 0 means that it's been turned off.
In my tests, it was on before the moveafterreturndirection line, but off right
after.
I don't know of any workaround (except not using the code!).
Ken McLennan wrote:
G'day there One and All,
Back again with another head scratcher.
In my ThisWorkBook object event code I've put in place a routine
to move the cursor down on exit from a cell if that cell is in the first
column. Any other cell has the usual cursor right. There are a few other
lines, but the code for this function is the culprit.
If I 'rem' it out, then copy works fine. If I deploy the code then
on that page I can't copy or cut anything. I can copy from another page
to cells there, but not from. If I select a range I get the "marching
ants" indicator, but when I select another cell to copy to they just
disappear and there's nothing in the clipboard.
I suspect that my code is interfering with the system's method of
using cursor movement in cut/copy procedures, but it's only a guess. In
any case, does anyone know how to get around the problem?
Thanks in advance,
Ken McLennan
Qld, Australia
Here's my code: (Which is paraphrased from suggestions given by Bernie
Deitrick & Tom Ogilvy)
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
' Set directions for cursor movement
On Error Resume Next
If Intersect(Target, Range("rosterBlockHd")) Is Nothing Then
If Sh.Name < "Roster - Diary Of Duty" Then Exit Sub
If Target.Column = 1 Then
Application.MoveAfterReturnDirection = xlDown
Else
Application.MoveAfterReturnDirection = xlToRight
End If
Else
MsgBox "Sorry, can't select Header Block cells"
Cells(6, Target.Column).Select
Exit Sub
End If
End Sub
--
Dave Peterson