あなたが(セルA1に開始)スプレッドシートの列Aにデータを持っていて、空のスペースをカウントし、次のように行を削除したいとします
Col A Col B Col A Col B
1 AAA AAA 2
2 BBB 1
3 CCC 0
4 BBB DDD 2
5 ---- Output ---> EEE
6 CCC
7 DDD
8
9
10 EEE
次のコードでその結果が得られます:
Sub CountEmptyRows()
Dim lastRow As Long, rw As Long, count As Integer
lastRow = Range("A65536").End(xlUp).Row - 1
count = 0
For rw = lastRow To 1 Step -1
If IsEmpty(Cells(rw, 1)) Then //If cell is empty increment the count and delete the row
count = count + 1
Cells(rw, 1).EntireRow.Delete
Else
Cells(rw, 2) = count //Display emtpy row count and then reset counter
count = 0
End If
Next rw
End Sub
まだ試しましたか?行の削除を自動化するには、VBAを使用する必要があります。これにVBAを使用することを検討しますか? –
はい、空の行を削除できるようになりました。しかし、問題はまだ私が上記のように空の行を数えることができますか? –