通过使用vba检查相邻的列值来删除整行

我有一个B列的string大约500行,我有单元格空/填充列A和C列值为M.

我写了一个macros,它将在B列中的每一行取得string值,如果该行的相邻单元格(从C列到M列)是空的,那么它将删除整行。 但是,即使任何一个相邻的单元格有值,那么它将跳过该行。

这是我的工作表

ABCDEFGHIJKLM 1.2 SERVER_P RE1 GR5 7.3 PROXY NET 4.5 NET CON V1 GR 

预计从coulms C到M为空应删除整个2行。 上面给出了三行,但是我的表包含大约500行数据。

这是我现在拥有的

 Dim rcount As Long, ccount As Long Dim Count As Long, Lastrow As Long Dim Targetname As String, Deletedname As String Dim objFSObject As Object Set objFSObject = CreateObject("Scripting.FileSystemObject") Count = 0 Sheets("Sheet2").Activate With ActiveSheet 'count the rows till which strings are there Lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row End With For rcount = 1 To Lastrow Targetname = Cells(rcount, 2).Value Count = 0 'reset the counter Cells(rcount, 2).Select For ccount = 1 To 11 Deletedname = ActiveCell.Offset(0, ccount).Value If Len(Trim$(Deletedname)) > 0 Then ccount = 11 Else Count = Count + 1 If Count = 11 Then Rows(rcount).EntireRow.Delete End If End If Next ccount Next rcount 

但是我的macros删除了许多满足条件的行,即C到M是空的,但是很less的行仍然没有被删除,它们的单元格也是从C列到M的空的。

有人能帮我解决这个问题吗?

在上面的@Logan Reed评论的帮助下

  Dim rcount As Long, ccount As Long Dim Count As Long, Lastrow As Long Dim Targetname As String, Deletedname As String Dim objFSObject As Object Set objFSObject = CreateObject("Scripting.FileSystemObject") Count = 0 Sheets("Sheet2").Activate With ActiveSheet 'count the rows till which strings are there Lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row End With For rcount = Lastrow to 1 Step -1 Targetname = Cells(rcount, 2).Value Count = 0 'reset the counter Cells(rcount, 2).Select For ccount = 1 To 11 Deletedname = ActiveCell.Offset(0, ccount).Value If Len(Trim$(Deletedname)) > 0 Then ccount = 11 Else Count = Count + 1 If Count = 11 Then Rows(rcount).EntireRow.Delete End If End If Next ccount Next