看过妖的QQ空间~~~~~有很多可学的东东啊....................作者: pureshadow 时间: 2008-2-23 16:29
有个高手写了个一次性选定所有未锁定单元格的代码,你可以试试。
Sub bb()
Dim mrg As Range, K As Integer
For Each mrg In ActiveSheet.UsedRange
If mrg.Locked = False Then
K = K + 1
If K = 1 Then mrg.Select
Union(Selection, mrg).Select
End If
Next mrg
End Sub
不错不错...
虽然速度还是稍显不足
不过已经是可以接受啦~~~~
谢谢小妖~~~~~~~~作者: pureshadow 时间: 2008-2-25 15:56
我师傅给了我个另类的代码,可以试试:
Sub test()
Dim vUnlocked As Variant
Dim rngUnlocked As Range
With ActiveSheet
If .ProtectContents = True Then .Unprotect
vUnlocked = .UsedRange
.UsedRange.ClearContents
.Protect
On Error Resume Next
.UsedRange.Value = 1
.Unprotect
Set rngUnlocked = .UsedRange.SpecialCells(xlCellTypeConstants)
.UsedRange = vUnlocked
rngUnlocked.Select
End With
selection.clearcontents
End Sub作者: w5xzm 时间: 2008-2-26 08:04
实在是高
Sub test()
Dim vUnlocked As Variant
Dim rngUnlocked As Range
With ActiveSheet
.Unprotect Password:="abcd" '<<<<这好象要加入解保护??
If .ProtectContents = True Then .Unprotect
vUnlocked = .UsedRange
.UsedRange.ClearContents
.Protect
On Error Resume Next
.UsedRange.Value = 1
.Unprotect
Set rngUnlocked = .UsedRange.SpecialCells(xlCellTypeConstants)
.UsedRange = vUnlocked
rngUnlocked.Select
.Protect Password:="abcd" '<<<< 这好象要加入加保护???
End With
Selection.ClearContents
End Sub