|
本帖最后由 zhaogang1960 于 2014-2-28 20:54 编辑
燕仔 发表于 2014-2-28 20:16
运行时错误'91‘ 对象变量或with块变量未设置 rngU.Copy Range("c" & r) 麻烦您再给看看。
加一个判断- Private Sub Worksheet_Activate()
- Dim arr, rng As Range, rngU As Range, m&, d As Date
- r = Sheets("Sheet1").Range("C65536").End(xlUp).Row
- If r < 8 Then Exit Sub
- Set rng = Sheets("Sheet1").Range("C8:Z" & r)
- arr = rng
- d = TimeValue(Now)
- For i = 1 To UBound(arr)
- If arr(i, 11) < d Then
- m = m + 1
- If m = 1 Then Set rngU = rng.Rows(i) Else Set rngU = Union(rngU, rng.Rows(i))
- End If
- Next
- If m = 0 Then Exit Sub '新加
- r = Range("C65536").End(xlUp).Row + 1
- If r < 8 Then r = 8
- rngU.Copy Range("c" & r)
- rngU.EntireRow.Delete
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|