|
请教下大神帮忙看看这代码哪里不行?我要删除掉cjmc的仓库所在的行,及J列为空的行;一行行判断太卡了,先感谢各位了;
Sub 删除多余行()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Dim arr As Variant, brr As Variant
nextrow = Sheets(1).Range("a2").End(xlDown).Row
nextcol = Sheets(1).Range("IV2").End(xlToLeft).Column
cjmc = Array("固定资产仓", "生产现场仓", "生产周转仓", "板材仓", "厂外仓", "物料仓", "合*计", "车间半成品周转仓", "车间仓", "来料加工仓")
arr = [a2].CurrentRegion
ReDim brr(1 To nextrow, 1 To nextcol)
For x = 1 To UBound(arr)
For y = 0 To UBound(cjmc)
If Cells(x, 2).Value <> cjmc(y) Or Cells(x, 10) <> "" Then
s = arr(x, 1) & "|" & arr(x, 2) & "|" & arr(x, 3) & "|" & arr(x, 4) & "|" & arr(x, _
5) & "|" & arr(x, 6) & "|" & arr(x, 7) & "|" & arr(x, 8) & "|" & arr(x, 9) & "|" & arr(x, 10)
t = d(s)
If t = "" Then
k = k + 1
d(s) = k
t = k
brr(k, 1) = arr(x, 1)
brr(k, 2) = arr(x, 2)
brr(k, 3) = arr(x, 3)
brr(k, 4) = arr(x, 4)
brr(k, 5) = arr(x, 5)
brr(k, 6) = arr(x, 6)
brr(k, 7) = arr(x, 7)
brr(k, 8) = arr(x, 8)
brr(k, 9) = arr(x, 9)
brr(k, 10) = arr(x, 10)
End If
End If
Next
Next
With ActiveSheet
.[a2].CurrentRegion.Offset(1) = Empty
.[a2].Resize(k, UBound(brr, 2)) = brr
End With
End Sub
|
|