ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste doesn't work (https://www.excelbanter.com/excel-programming/273171-paste-doesnt-work.html)

Wen

Paste doesn't work
 
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[_3_]

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


Wen

Paste doesn't work
 
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 wrote in message ...
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



All times are GMT +1. The time now is 12:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com