0
Excel 2016 - ユーザーが列Dに "CRED"と入力すると、行全体をコピーして次の行に挿入する必要があります。VBA - 行を挿入する値としてコピー&ペーストの式
次のコードは、RECMER(列D)の新しいコードを含む次の行AOKを挿入します。これに加えて、式(列C)を次の行の同じ列の値としてコピー/貼り付けする必要があります。
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errHnd
'Don't do anything if more than one cell has been changed
If Target.Cells.Count > 1 Then Exit Sub
'Determine if the changed cell is in Column C and is a Y
If Target.Column = 4 Then
If Target = "CRED" Then
'Disable events so code doesn't fire again when row is inserted
Application.EnableEvents = False
'Copy & Insert changed Row, Clear dotted lines
Target.EntireRow.Copy
Range("A" & Target.Row + 1).Insert Shift:=xlDown
Application.CutCopyMode = False
'Put 2201 in Column B of inserted Row
Range("D" & Target.Row + 1) = "RECMER"
End If
End If
errHnd:
'Re-enable event
Application.EnableEvents = True
End Sub
- 非常に感謝を! – Steph