Header ads

Header ads
» » Hàm Sum nhiều tính năng

Mình gửi đến các bạn vài hàm Sum tự tạo nhằm đa dạng hóa tính năng cộng của hàm Sum

Đầu tiên là hàm SumType :
Chức năng :
- Cộng các ô có chứa hay không chứa công thức.
- Cộng các ô có hay không có màu nền
- Cộng các ô có hay không có màu Font chữ
- Cộng các ô có hay không có Font chữ in đậm
- Bỏ qua các ô bị lỗi khi cộng
Link hàm: Sum.xls
Code:
Public Function SumType(TypeFunc As ByteOpt As BooleanRng1 As Range_
      Optional Rng2 
As RangeOptional Rng3 As RangeOptional Rng4 As Range_
      Optional Rng5 
As Range) As Double
Dim Cell 
As RangeSumT As DoubleFor Each Cell In Rng1If Not IsError(CellThen
    
If IsNumeric(CellThen
    Select 
Case TypeFunc
    
Case 'cong cac cell dang value hay formula.'
        
If Cell.HasFormula Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau nen.'
        
If Cell.Interior.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau font chu.'
        
If Cell.Font.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co hay khong co font in dam.'
        
If Cell.Font.Bold Opt Then SumT SumT Cell
    End Select
    End 
IfEnd IfNext'---------------------------------------------------------------------'If Not Rng2 Is Nothing ThenFor Each Cell In Rng2If Not IsError(CellThen
    
If IsNumeric(CellThen
    Select 
Case TypeFunc
    
Case 'cong cac cell dang value hay formula.'
        
If Cell.HasFormula Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau nen.'
        
If Cell.Interior.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau font chu.'
        
If Cell.Font.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co hay khong co font in dam.'
        
If Cell.Font.Bold Opt Then SumT SumT Cell
    End Select
    End 
IfEnd IfNext
End 
If'---------------------------------------------------------------------'If Not Rng3 Is Nothing ThenFor Each Cell In Rng3If Not IsError(CellThen
    
If IsNumeric(CellThen
    Select 
Case TypeFunc
    
Case 'cong cac cell dang value hay formula.'
        
If Cell.HasFormula Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau nen.'
        
If Cell.Interior.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau font chu.'
        
If Cell.Font.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co hay khong co font in dam.'
        
If Cell.Font.Bold Opt Then SumT SumT Cell
    End Select
    End 
IfEnd IfNext
End 
If'---------------------------------------------------------------------.'If Not Rng4 Is Nothing ThenFor Each Cell In Rng4If Not IsError(CellThen
    
If IsNumeric(CellThen
    Select 
Case TypeFunc
    
Case 'cong cac cell dang value hay formula.'
        
If Cell.HasFormula Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau nen.'
        
If Cell.Interior.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau font chu.'
        
If Cell.Font.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co hay khong co font in dam.'
        
If Cell.Font.Bold Opt Then SumT SumT Cell
    End Select
    End 
IfEnd IfNext
End 
If'---------------------------------------------------------------------.'If Not Rng5 Is Nothing ThenFor Each Cell In Rng5If Not IsError(CellThen
    
If IsNumeric(CellThen
    Select 
Case TypeFunc
    
Case 'cong cac cell dang value hay formula.'
        
If Cell.HasFormula Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau nen.'
        
If Cell.Interior.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co mau hay khong co mau font chu.'
        
If Cell.Font.ColorIndex Opt Then SumT SumT Cell
    
Case 'cong cac cell co hay khong co font in dam.'
        
If Cell.Font.Bold Opt Then SumT SumT Cell
    End Select
    End 
IfEnd IfNext
End 
IfSumType SumT
End 
Function 

About Học viện đào tạo trực tuyến

Xinh chào bạn. Tôi là Đinh Anh Tuấn - Thạc sĩ CNTT. Email: dinhanhtuan68@gmail.com .
- Nhận đào tạo trực tuyến lập trình dành cho nhà quản lý, kế toán bằng Foxpro, Access 2010, Excel, Macro Excel, Macro Word, chứng chỉ MOS cao cấp, IC3, tiếng anh, phần mềm, phần cứng .
- Nhận thiết kế phần mềm quản lý, Web, Web ứng dụng, quản lý, bán hàng,... Nhận Thiết kế bài giảng điện tử, số hóa tài liệu...
HỌC VIỆN ĐÀO TẠO TRỰC TUYẾN:TẬN TÂM-CHẤT LƯỢNG.
«
Next
Bài đăng Mới hơn
»
Previous
Bài đăng Cũ hơn