View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Paste doesn't work

A lot of macros kill the Edit|Undo feature. And lots of macros kill the
cutcopymode flag.

Maybe you could have your own version of cut/copy and paste.

Add a "application.enableevents = false" before selecting your "to" range. And
then turn it back on.

But then you'd have to write the equivalent of the Workbook_SheetSelectionChange
code.

And this might not be useful to you, but I could do this:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)

If Application.CutCopyMode < False Then Exit Sub

''''rest of sub
end sub

and then the copy|paste still worked. But that did kill the rest of your sub.

====
And if you're copying while you're developing, you can temporarily suspend the
events by going into the vbe and hitting ctrl-G (to see the immediate window)
and typing:

application.EnableEvents = False
do your development and turn it back on for testing:
application.EnableEvents = True




Wen wrote:

Hello,
I'd created the following macro in Thisworkbook. But because of this,
the paste function doesn't work any more.
Can someone help?

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)

[a3:iq5000].Interior.ColorIndex = 0

If Target.Row 2 Then
T = "J" & Target.Row & ":K" & Target.Row
Range(T).Interior.ColorIndex = 6
End If

End Sub

Best Regards
Wen


--

Dave Peterson