Mã:
Public Function SumPower(TypeFunc As Byte, Source As Variant, ParamArray AllRange() As Variant) As Double
Dim Rng As Variant, Cell As Range, SumT As Double
Application.Volatile
With WorksheetFunction
Select Case TypeFunc
Case 1 'Cong các ô có hay không có chua Giá Tri Loi
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If -IsError(Cell) = Source Then SumT = .Sum(SumT, Cell)
Next
Next
GoTo Finish
Case 2 'Cong các ô có Giá Tri bang gia tri nguon "Source"
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If Val(Cell) = Source Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
GoTo Finish
Case 3 'Cong các ô có Giá Tri nho hon gia tri nguon "Source"
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If Val(Cell) < Source Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
GoTo Finish
Case 4 'Cong các ô có Giá Tri lon hon gia tri nguon "Source"
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If Val(Cell) > Source Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
GoTo Finish
Case 5 'Cong các ô có hay không có chua Công Thuc
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If -Cell.HasFormula = Source Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
GoTo Finish
Case 6 'Cong các ô có hay không có chua Font Chu In Dam
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If -Cell.Font.Bold = Source Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
GoTo Finish
Case 7 'Cong các ô có hay không có chua Mau Font Chu
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If -(Cell.Font.ColorIndex > 0) = Source Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
GoTo Finish
Case 8 'Cong các ô có chua Mau Font Chu tuong tu nhu ô goc "Source"
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If Cell.Font.ColorIndex = Source.Font.ColorIndex Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
GoTo Finish
Case 9 'Cong các ô có hay không có chua Mau Nen
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If -(Cell.Interior.ColorIndex > 0) = Source Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
GoTo Finish
Case 10 'Cong các ô có chua Mau Nen tuong tu nhu ô goc "Source"
For Each Rng In AllRange()
For Each Cell In Union(Rng.SpecialCells(2, 19), Rng.SpecialCells(-4123, 19))
If Not IsError(Cell) Then
If Cell.Interior.ColorIndex = Source.Interior.ColorIndex Then
SumT = .Sum(SumT, Val(Cell))
End If
End If
Next
Next
End Select
End With
Finish: SumPower = SumT
End Function
-----------------------------------------------------------------------------------------
Vòng tay phong thủy là một vật phẩm mang lại sự may mắn trong tài lộc, tình duyên, sự nghiệp,.. Là một vật phẩm không xa lạ gì với chúng ta, vòng tay phong thủy có nhiều màu, đa dạng và mỗi màu sắc...
Công dụng và bí quyết phân loại vòng tay phong thủy chính xác