|
Dim mbCut As
Boolean
Dim mRng As Range
Sub InitCutCopy()
'设定/初此化快捷键
With Application
'CTRL+X
.OnKey "^x", "DoCut"
.OnKey "^X", "DoCut"
.OnKey "+{DEL}", "DoCut"
'CTRL+C
.OnKey "^c", "DoCopy"
.OnKey "^C", "DoCopy"
.OnKey "^{INSERT}", "DoCopy"
'CTRL+V
.OnKey "^v", "DoPaste"
.OnKey "^V", "DoPaste"
.OnKey "+{INSERT}", "DoPaste"
'关掉单元格的拖动功能,你也可以不<SPAN class=t_tag onclick=tagshow(event) href="tag.php?name=%C9%E8%D6%C3">设置</SPAN>
.CellDragAndDrop = False
End
With
End
Sub
Sub DoCut()
If
TypeOf Selection Is Range Then
mbCut = True
Set mRng = Selection
'复制到剪切板上
Selection.Copy
Else
mRng = Nothing
'剪切到剪切板上
Selection.Cut
End
If
End
Sub
Sub DoCopy()
If
TypeOf Selection Is Range Then
mbCut = False
Set mRng = Selection
Else
mRng = Nothing
End
If
'复制到剪切板上
Selection.Copy
End
Sub
Sub DoPaste()
If Application.CutCopyMode And
Not (mRng Is
Nothing) Then
'贴为数值
Selection.PasteSpecial xlValue
'如果是CUT模式,清除旧数据
If mbCut Then mRng.ClearContents
Set mRng = Nothing
Else
'如果不是RANGE对象,直接粘贴
If Application.CutCopyMode Then ActiveSheet.Paste
End
If
'清空剪切板
Application.CutCopyMode = False
End
Sub |
|