作者:乔山办公网日期:
返回目录:excel表格制作
一般采抄用倒序的方式百:例如,将度D列中为“否”知的整行删除:道
Sub test()
For i = Cells(Rows.Count, 4).End(xltoup).Row To 1
If Range("D" & i) = "否" Then
Range("D" & i).EntireRow.Delete
End If
Next
End Sub
1、首先打开需要编辑的Excel表格,右键单击copy工作表的标签,选择打开“查百看代码”。
2、然后在弹出来的窗口中点击输入:
Sub 删除重复行()
Dim xRow As Integer
Dim i As Integer
xRow = Range("B65536").End(xlUp).Row
For i = 2 To xRow
For j = i + 1 To xRow
If Cells(j, 2) = Cells(i, 2) Then
Range(Cells(j, 1), Cells(j, 256)).Rows.Delete
j = j - 1
xRow = xRow - 1
End If
Next
Next
End Sub
3、然后点击左上角的保度存按钮进行保存,之后运行该代知码或运行宏“删除重复行”即可。
4、然后就可以删除重复数据的整道行。
Dim cel As Range, i As Integer
For i = 1 To 100
Set cel = Range("a" & i)
If Application.WorksheetFunction.CountIf(Range(Range("a1:a100"), cel), cel) > 1 Then
cel.EntireRow.Delete shift:=xlUp
i = i - 1
End If
Next
字典百 CreateObject("scripting.dictionary")
我的一段代码,度供参考。知
Set d = CreateObject("scripting.dictionary")
For Each Rng In Worksheets("原始表道回").Range("c1:c" & Rcount)
If Not d.exists(Rng.Value) And Worksheets("原始表").Cells(Rng.Row, 1) = 2 Then d.Add Rng.Value, ""
Next
Worksheets("支路模答块矩阵").Range("b1").Resize(1, d.Count) = d.keys
Set d = Nothing