一、输入数据自动锁定
Private Sub Worksheet_SelectionChange(ByVal
Target As Range)
On
Error Resume Next
Sheet1.Unprotect Password:="123"
If
Target.Value <> "" Then
Target.Locked = True
Sheet1.Protect Password:="123"
End
If
End Sub
Sheet1.Unprotect Password:="123"
Sheet1.Protect Password:="123"
二、根据批注提取数据
Public Function pizhu(i As Range)
Application.Volatile True
pizhu = i.Cells.Comment.Text
End Function
三、根据颜色求和
Function SumColor(i As Range, ary1 As
Range)
Dim
icell As Range
Application.Volatile
For
Each icell In ary1
If
icell.Interior.ColorIndex = i.Interior.ColorIndex Then
SumColor = Application.Sum(icell) + SumColor
End
If
Next
icell
End Function
四、根据颜色计数
Function CountColor(x As Range, ary2 As
Range)
Application.Volatile
For Each i In ary2
If i.Interior.ColorIndex =
x.Interior.ColorIndex Then
CountColor = CountColor + 1
End If
Next
End Function
想要学Excel,可以点击超链接,了解下我的课程,带你成为Excel高手提高工作效率,仅售49.9
END