Skip to content

Instantly share code, notes, and snippets.

@hedgejanuary
Last active May 6, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hedgejanuary/736e02aa00c6be2c61aaea249f3943d1 to your computer and use it in GitHub Desktop.
Save hedgejanuary/736e02aa00c6be2c61aaea249f3943d1 to your computer and use it in GitHub Desktop.
Cleaning up excel data (2 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
'1行目から最終行までIf以下を繰り返す
For i = 1 to LastRow
'偶数行の場合は、値をB列に移動させる
If i Mod 2 = 0 Then
Cells(i, "A").Cut Cells(i-1,"B")
End if
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