データは 1 列しかありません。すべての値を調べて、"paper" という単語を含むすべての行を削除するマクロを作成する必要があります。
A B
1 678
2 paper
3 3
4 09
5 89
6 paper
問題は、行数が固定されていないことです。シートの行数が異なる場合があります。
これは、列 A (行 1 以外) に数値以外の値を持つすべての行を削除する別の単純なマクロです。
Sub DeleteRowsWithStringsInColumnA()
Dim i As Long
With ActiveSheet '<~~ Or whatever sheet you may want to use the code for
For i = .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, 1).Row To 2 Step -1 '<~~ To row 2 keeps the header
If IsNumeric(.Cells(i, 1).Value) = False Then .Cells(i, 1).EntireRow.Delete
Next i
End With
End Sub
以下は、文字列または数値を入力して、それぞれの行を検索および削除できる柔軟なマクロです。104 万行の単純な文字列と数値を 2.7 秒で処理できます。
Sub DeleteRows()
Dim Wsht As Worksheet
Dim LRow, Iter As Long
Dim Var As Variant
Var = InputBox("Please specify value to find and delete.")
Set Wsht = ThisWorkbook.ActiveSheet
LRow = Wsht.Cells(Rows.Count, 1).End(xlUp).Row
StartTime = Timer
Application.ScreenUpdating = False
With Wsht
For Iter = LRow To 1 Step -1
If InStr(.Cells(Iter, 1), Var) > 0 Then
.Cells(Iter, 1).EntireRow.Delete
End If
Next Iter
End With
Application.ScreenUpdating = True
Debug.Print Timer - StartTime
End Sub