0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

削除フラグと行の削除

Posted at

Excel VBA
削除フラグと行の削除


'[削除フラグ]列に"d"と入力された行をすべて削除

Sub DeleteRows()

    '最終行を取得する
    Dim maxRow As Long
    maxRow = Cells(Rows.Count, 1).End(xlUp).Row

    '行を1つずつ見ていく(maxRow→2へ下がっていく)
    Dim i As Long
    For i = maxRow To 2 Step -1
    
        '"d"と書かれているかどうか(判断)
        If Range("G" & i).Value = "d" Then
            
            '行の削除
            Rows(i).Delete
        
        End If
    
    Next i

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?