|
楼主 |
发表于 2011-9-30 13:13
|
显示全部楼层
- Sub test1()
- Dim rng1, rng2, rng3
- Set rng1 = Sheet1.UsedRange
- Set rng2 = Range("A1")
- Set rng3 = Application.Intersect(rng1, rng2)
- If rng3 Is Nothing Then
- MsgBox "未使用过"
- Else
- MsgBox "使用过"
- End If
- End Sub
复制代码
- Sub test2()
- Dim x, s
- For Each x In Sheet3.UsedRange
- s = s & x.Address(0, 0) & ","
- Next x
- MsgBox s
- End Sub
复制代码- Sub test3() 'mxg825
- If Application.CountA(Sheet1.UsedRange.Cells) = 0 Then '是否为空工作表 未使用
- MsgBox "空工作表"
- Else
- MsgBox "不是工作表"
- End If
- End Sub
复制代码
谢谢825!
看来,都得和usedrange属性打交道。发现个有趣情况:test1和test2对于A1单元格的判断,都显得无能为力。因为是空白工作表,EXCEL也认为A1单元格使用过。
test3是最简便的办法么{:041:}
|
|