Skip to content

Instantly share code, notes, and snippets.

@hedgejanuary
Last active May 6, 2019 19:58
Show Gist options
  • Save hedgejanuary/67a5cb77daef7490e2b705def4ac45d4 to your computer and use it in GitHub Desktop.
Save hedgejanuary/67a5cb77daef7490e2b705def4ac45d4 to your computer and use it in GitHub Desktop.
Cleaning up excel data (3 columns)
Option Explicit
Sub CleanUpData()
Dim i As Long
Dim LastRow As Long
'空白行を削除
Range("A:A").Cells.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
'データの最終行
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
'アイテムがある行まで以下を繰り返す
For i = 1 to LastRow - 2
3行おきに新しいアイテムが始まっているので、3の倍数で。
Cells(3 * i - 1, "A").Cut Cells(3 * i -2, "B")
Cells(3 * i , "A").Cut Cells(3 * i - 2, "C")
Next i
'もう一回、空白行を削除
Range("A:A").Cells.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment