Last active
May 6, 2019 19:58
-
-
Save hedgejanuary/67a5cb77daef7490e2b705def4ac45d4 to your computer and use it in GitHub Desktop.
Cleaning up excel data (3 columns)
This file contains hidden or 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
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