Last active
March 9, 2023 23:51
-
-
Save okash1n/b2ab74ecbcdaab88fb9cfb4c173afe4e to your computer and use it in GitHub Desktop.
特定の列に値が入っていたら、一行追加して特定列をコピーするVBAスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub insertRowAndCopyValue() | |
' | |
' insertRowAndCopyValue | |
' T列に値が入っていたら下に行を追加して、その行に各種値をコピーする(一行目は除く) | |
' | |
' | |
Dim lastRow As Long | |
Dim i As Long | |
lastRow = Range("T" & Rows.Count).End(xlUp).Row | |
For i = lastRow To 2 Step -1 | |
If Range("T" & i).Value <> "" Then | |
Rows(i + 1).Insert Shift:=xlDown | |
Range("J" & i + 1).Value = Range("T" & i).Value | |
Range("F" & i + 1).Value = Range("F" & i).Value | |
Range("W" & i + 1).Value = Range("T" & i).Value | |
Range("L" & i + 1).Value = 0 | |
Range("AC" & i + 1).Value = 5 | |
End If | |
Next i | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment