Home
Blog
Inquire

VBA

VBA--- エクセル:空白行を削除


会計ソフト等からエクスポートしたエクセルデータの不要な空白行を削除したかったので作成(説明は省略)

 Sub 空白行del()
  Dim endrowcnt,endcolcnt,rowcnt,colcnt As Long
  Dim flg As Boolean
  With ActiveSheet
   endrowcnt = .Range("E" & Cells.Rows.Count).End(xlUp).Row
   endcolcnt = .Range("XFD1").End(xlToLeft).Column
   For rowcnt = endrowcnt To 2 Step -1
    flg = false
    For colcnt = 1 To endcolcnt
     If .Cells(rowcnt, colcnt) <> "" Then
      flg = true
      Exit For
     End If
    Next colcnt
    If flg = false Then
     .Rows(rowcnt).Delete
    End If
   Next rowcnt
 End Sub

   


©2018KanazawaNoSakai