Sub InsertBlankRowsAtIntervals()
Dim ws As Worksheet
Dim lastRow As Long, n As Long, i As Long
Dim colC As Long, lastCol As Long
' カスタマイズ可能な変数
n = 5 ' ここでnの値を設定します。n行ごとに空白行を挿入
Set ws = ActiveSheet
lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row ' C列での最後の行を取得
lastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column ' 最後の列を取得
' 最後の行から始めて、n行ごとに繰り返し
For i = lastRow To 2 Step -n
ws.Rows(i + 1 & ":" & i + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
' 挿入した空白行のC列から右端までの範囲を選択
ws.Range(ws.Cells(i + 1, 3), ws.Cells(i + 1, lastCol)).Select
Next i
End Sub
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme