Paste doesn't work

  • Thread starter Thread starter Wen
  • Start date Start date
W

Wen

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
 
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



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
 
Hello Dave,
"If Application.CutCopyMode <> False Then Exit Sub" is exact what I'm looking for.
Thank you very much.
The best regards
Wen

Dave Peterson said:
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



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
 
Back
Top