تعرف على طريقة مميزة لحساب عدد الخلايا حسب لون الخلية في إكسل.
تنويه: يجب حفظ ملف العمل بصيغة excel macro enabled بعد إضافة الكود البرمجي لضمان حفظ الملف بشكل صحيح.
الكود المستخدم في الفيديو:
Function CountCellsByColor(data_range As Range, cell_color As Range) As Long
Dim indRefColor As Long
Dim cellCurrent As Range
Dim cntRes As Long
Application.Volatile
cntRes = 0
indRefColor = cell_color.Cells(1, 1).Interior.Color
For Each cellCurrent In data_range
If indRefColor = cellCurrent.Interior.Color Then
cntRes = cntRes + 1
End If
Next cellCurrent
CountCellsByColor = cntRes
End Function
Function CountCellsByFontColor(data_range As Range, font_color As Range) As Long
Dim indRefColor As Long
Dim cellCurrent As Range
Dim cntRes As Long
Application.Volatile
cntRes = 0
indRefColor = font_color.Cells(1, 1).Font.Color
For Each cellCurrent In data_range
If indRefColor = cellCurrent.Font.Color Then
cntRes = cntRes + 1
End If
Next cellCurrent
CountCellsByFontColor = cntRes
End Function
حساباتنا على وسائل التواصل الاجتماعي:
تيك توك
فيس بوك
إنستغرام
تيليجرام
https://t.me/HaniTechChannel
يمكنكم التواصل معنا دائماً عبر البريد الرسمي للقناة
#excel #exceltutorial
#productivity