数値以外の行を削除

Visual Basic for Applications

Sub Macro()
  Dim Sheet As Integer
  Dim ccc As Integer
  Dim MSG As String
  Dim BeginRow As Integer
  Dim EndRow As Integer
  Dim rrr As Integer
  Dim DateData As Date
  Dim tmp
  Sheet = 12
  ccc = 2 '数値データの有無を確認する列
  MSG = "Input Beginnig Row"
  BeginRow = InputBox(MSG)
  EndRow = Worksheets(Sheet).Cells(BeginRow, 1).End(xlDown).Row
  For rrr = BeginRow To EndRow
    tmp = Replace(Worksheets(Sheet).Cells(rrr, 1), "-0", "/")
    DateData = Replace(tmp, "-", "/")
    Worksheets(Sheet).Cells(rrr, 1) = DateData
    tmp = Worksheets(Sheet).Cells(rrr, ccc)
    If IsError(tmp) = True Or IsEmpty(tmp) = True Or IsNumeric(tmp) = False Then '数値ではない行を削除
      Rows(rrr).Select
      Selection.Delete Shift:=xlUp
      rrr = rrr - 1
      EndRow = EndRow - 1
    End If
    If rrr + 1 > EndRow Then
      Exit For
    End If
  Next
  Worksheets(Sheet).Select
  Cells(1, 1).Select
End Sub