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
-----------------------------------------------------------------------------------------
Ngọc Bích xanh bản tính thuộc dòng đá đá hoa (jade). Và đá hoa là tên gọi chung của ngọc bích. Vì bản tính chúng thuộc dòng đá đa khoáng được hình thành từ chất Silicat dưới dạng dioxy. Ngọc bích...
Chia sẻ Vòng tay ngọc bích xanh là gì? (5) Có hiệu quả gì cho sức khỏe