如果A
= {{1} {{1}将B
复制到A14
。
我有这段代码,但大多数情况下,"zois"
中的空白单元格会在"zois"
中删除未复制的值。
B14
答案 0 :(得分:0)
您在 A 列中输入的内容将被复制到 B 列(甚至空白!!)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, intr As Range, r As Range
Set A = Range("A:A")
Set intr = Intersect(A, Target)
If intr Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each r In intr
r.Copy r.Offset(0, 1)
Next r
Application.EnableEvents = True
End Sub
修改#1:强>
如果 A 中的值被清除,此版本将不清除 B 列中的值:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, intr As Range, r As Range
Set A = Range("A:A")
Set intr = Intersect(A, Target)
If intr Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each r In intr
If r.Value <> "" Then
r.Copy r.Offset(0, 1)
End If
Next r
Application.EnableEvents = True
End Sub
在安装新版本之前,请务必删除旧版本。