尝试在单元格中设置双击以剪切文本和格式,然后在另一个单元格中单击一下即可剪切剪切文本和格式。当前代码仅将未格式化的文本粘贴到新单元格中。
这是我现在拥有的
Option Explicit
Dim CutValue
Dim CutCell As Range
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Target.Cut
CutValue = Target.Text
Set CutCell = Target
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not IsEmpty(CutValue) Then
Target.FormulaR1C1 = CutValue
CutValue = Empty
CutCell.Clear
End If
End Sub
非常感谢任何帮助。
答案 0 :(得分:0)
您可以延迟剪切,直到用户选择另一个单元格:
Option Explicit
Dim CutCell As Range
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Set CutCell = Target
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not CutCell Is Nothing Then
CutCell.Cut Target.Cells(1) '<<<in case of multi-cell selection...
Set CutCell = Nothing
End If
End Sub