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
-----------------------------------------------------------------------------------------
Trong tương lai, mong rằng sự phát triển của ngành công nghiệp Đồ Thờ Gỗ sẽ tiếp tục mang lại những sản phẩm chất lượng cao, đẳng cấp và ý nghĩa cho người tiêu dùng, đồng thời góp phần bảo tồn và...
Nét Tâm Linh Tinh Tế: Skyhome.vn và Đặc Trưng của Tranh Thờ, Tranh Trúc Chỉ