-
worksheet events issue
Hi all!
Is there a way to understand which kind of event occured on a worksheet?
I'm trying to trigger an event if the user press "Copy" or tries to copy any cell of the activesheet.
colud it be, associated with selection_change,
[VBA]if application.cutcopymode=true then
'do it
else
do nothing
end if[/VBA]
?
-
Hi Ale,
"True" doen't work for me, so maybe that is your problem too.
try
[vba]
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.CutCopyMode = 1 Then
MsgBox "Someone is trying to copy this"
Application.CutCopyMode = 0
End If
End Sub
[/vba]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
If you just want to stop them copying...
[VBA]
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.CutCopyMode = Not Application.CutCopyMode
End Sub
[/VBA]
You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you
The major part of getting the right answer lies in asking the right question...
Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.
-
they don't work. Both codes are triggered when the change of selection has been made.
To understand what I mean try to select copy then activate another workbook and select paste. The code won't be executed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules