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
-----------------------------------------------------------------------------------------
Bạn đang quan tâm đến dịch vụ thu hẹp vùng kín. Bạn không biết có nên thu hẹp vùng kín và địa chỉ thu hẹp vùng kín uy tín tại Đà Nẵng. Hãy cùng Viện thẩm mỹ Viola Eva – Trung tâm thẩm mỹ vùng kín Đà...
Thu hẹp vùng kín tại Đà Nẵng: Giải đáp câu hỏi có nên thực hiện