Copy&Paste and Selection Change

B

Bura Tino

Hi,

My worksheet has a Worksheet_SelectionChange event. An unfortunate side
effect of this is that I can no longer copy and paste. If I have something
on the clipboard, it dissappears once I click on the target cell. (You know,
how ability to paste disappears once you do anything...)

Can anyone suggest a work around?


Thanks,

Bura
 
A

Anders S

Bura,

'-----
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Beep
End Sub
'-----

The above code does not cancel Copy, so I don't think it is Worksheet_SelectionChange in itself that is the problem. Set a breakpoint in the beginning of your code and step through the code with F8 and watch when the Copy is cancelled. Or post your code.

HTH
Anders Silvén
 
B

Bura Tino

Anders S said:
Bura,

'-----
Private Sub Worksheet SelectionChange(ByVal Target As Range)
Beep
End Sub
'-----

The above code does not cancel Copy, so I don't think it is
Worksheet SelectionChange in itself that is the problem. Set a
breakpoint in the beginning of your code and step through the code with
F8 and watch when the Copy is cancelled. Or post your code.

You are right. My code is below. Making the boutton visible is what
does it.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Column = 7 And Target.Columns.count = 1 And Target.Row
= 16 And (Target.Row + Target.Rows.count < 36) Then
AddFundButton.Visible = True
AddFundButton.Top = Target.Top
Else
AddFundButton.Visible = False
End If
End Sub
 
A

Anders S

Bura,

The following short version of your code confirms the problem. I have no idea why it happens.

I suggest you start a new thread based on what we have found out this far. You may mention that the button is from the Controls Toolbar.

'-----
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$A$1" Then
AddFundButton.Visible = True
Else
AddFundButton.Visible = False
End If
End Sub
'-----

Best regards,
Anders Silven

"Anders S" <[email protected]> skrev i meddelandet Bura,

'-----
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Beep
End Sub
'-----

The above code does not cancel Copy, so I don't think it is Worksheet_SelectionChange in itself that is the problem. Set a breakpoint in the beginning of your code and step through the code with F8 and watch when the Copy is cancelled. Or post your code.

HTH
Anders Silvén
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top