在 excel 上复制并粘贴而不删除单元格当前内容
copy and paste on excel without deleting cells current content
我正在尝试创建一个单元格以在 excel 中构建罐头回复电子邮件。我需要能够将文本粘贴到单元格中而不删除该单元格中已经存在的信息(并且我需要能够重复执行此操作。)我基本上是在寻求帮助创建一个具有类似 'copy and paste' 作为 word 文档的属性。即当我将文本粘贴到单元格中时,它会将新文本插入到先前文本的下方,而不是用剪贴板替换现有文本。
我绝对可以在 VBA 中使用一些编码帮助。如果有任何需要澄清的地方,请告诉我!谢谢
我写了代码来完成你的要求,但我不确定它是否真的是你需要的。
按Alt+F11
双击您希望它在其上工作的工作表(左侧)
粘贴此代码。
请注意,此代码将允许您通过点击删除来清除单元格。
否则很难删除
请注意,这实际上会附加您尝试编辑的任何单元格。
Dim currentVal
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If currentVal <> vbNullString And Target.Value <> vbNullString Then
Application.EnableEvents = False
Target.Value = currentVal & vbCrLf & Target.Value
currentVal = Target.Value
Application.EnableEvents = True
Else
currentVal = Target.Value
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.CountLarge = 1 Then currentVal = Target.Value
End Sub
工作原理:
希望最终编辑能够处理在无法测试的移动设备上键入的合并单元格:
Dim currentVal
Private Sub Worksheet_Change(ByVal Target As Range)
If currentVal <> vbNullString And Target.Cells(1,1).Value <> vbNullString Then
Application.EnableEvents = False
'Use this to add an extra line instead
Target.Cells(1,1).Value = currentVal & vbLf & vbLf & Target.Cells(1,1).Value
'Target.Cells(1,1).Value = currentVal & vbLf & Target.Cells(1,1).Value
currentVal = Target.Cells(1,1).Value
Application.EnableEvents = True
Else
currentVal = Target.Cells(1,1).Value
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
currentVal = Target.Cells(1,1).Value
End Sub
我正在尝试创建一个单元格以在 excel 中构建罐头回复电子邮件。我需要能够将文本粘贴到单元格中而不删除该单元格中已经存在的信息(并且我需要能够重复执行此操作。)我基本上是在寻求帮助创建一个具有类似 'copy and paste' 作为 word 文档的属性。即当我将文本粘贴到单元格中时,它会将新文本插入到先前文本的下方,而不是用剪贴板替换现有文本。
我绝对可以在 VBA 中使用一些编码帮助。如果有任何需要澄清的地方,请告诉我!谢谢
我写了代码来完成你的要求,但我不确定它是否真的是你需要的。
按Alt+F11
双击您希望它在其上工作的工作表(左侧)
粘贴此代码。
请注意,此代码将允许您通过点击删除来清除单元格。
否则很难删除
请注意,这实际上会附加您尝试编辑的任何单元格。
Dim currentVal
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If currentVal <> vbNullString And Target.Value <> vbNullString Then
Application.EnableEvents = False
Target.Value = currentVal & vbCrLf & Target.Value
currentVal = Target.Value
Application.EnableEvents = True
Else
currentVal = Target.Value
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.CountLarge = 1 Then currentVal = Target.Value
End Sub
工作原理:
希望最终编辑能够处理在无法测试的移动设备上键入的合并单元格:
Dim currentVal
Private Sub Worksheet_Change(ByVal Target As Range)
If currentVal <> vbNullString And Target.Cells(1,1).Value <> vbNullString Then
Application.EnableEvents = False
'Use this to add an extra line instead
Target.Cells(1,1).Value = currentVal & vbLf & vbLf & Target.Cells(1,1).Value
'Target.Cells(1,1).Value = currentVal & vbLf & Target.Cells(1,1).Value
currentVal = Target.Cells(1,1).Value
Application.EnableEvents = True
Else
currentVal = Target.Cells(1,1).Value
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
currentVal = Target.Cells(1,1).Value
End Sub