Need to edge out the competition for your dream job? Train for certifications today.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.CutCopyMode = 1 Or _
Application.CutCopyMode = 2 Then
MsgBox "you hit control c before that selection change!"
Open in new window
Private Sub AssignMacro(ByVal strProc As String)
Dim lngId As Long
Dim CtrlCbc As CommandBarControl
Dim CtrlCbcRet As CommandBarControls
Dim arrIdNum As Variant
' 295 Insert Cells from worksheet menu
' 296 Insert rows from worksheet menu
' 945 Insert from right click menu
arrIdNum = Array(19)
For lngId = LBound(arrIdNum) To UBound(arrIdNum)
Set CtrlCbcRet = CommandBars.FindControls(ID:=arrIdNum(lngId))
If Not CtrlCbcRet Is Nothing Then
For Each CtrlCbc In CtrlCbcRet
CtrlCbc.OnAction = strProc
Set CtrlCbcRet = Nothing
Application.OnKey "^c", "RunHello"
Application.OnKey "^c", vbNullString
MsgBox "You Pressed the CTRL+c Key combo"
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.