具有非常庞大的Excel数据。我想将数据从C列复制到有条件的其他工作表中。具有n个文本值的C列只希望重复包含少于100次的单词。
Sub DelR()
Dim myRow As Range
Dim to Delete As Range
For I=2 to 10000
If workseets("Sheet1").Cells(I,2) >100 Then
Set myRow = Worksheets("Sheet1").Rows(I)
If toDelete = myRow Else
Set to Delete = Union(toDelete, myRow)
End If
End If
Next I
If Not toDelete Is Nothing Then toDelete.EntireRow.Delete
End Sub
答案 0 :(得分:1)
Sub DelR()
Dim sht As WorkSheet
Dim myRow As Range
Dim to Delete As Range
Set sht = worksheets("Sheet1")
For I=2 to 10000
If Application.Countif(sht.Columns(2), _
sht.Cells(I,2).Value) >100 Then
Set myRow = sht.Rows(I)
If toDelete Is Nothing
Set toDelete = myRow
Else
Set toDelete = Application.Union(toDelete, myRow)
End If
End If
Next I
If Not toDelete Is Nothing Then toDelete.EntireRow.Delete
End Sub