Тёмный

Excel VBA Macro: Count Conditionally Formatted Cells (Dynamic Range) 

greggowaffles
Подписаться 6 тыс.
Просмотров 5 тыс.
50% 1

Excel VBA Macro: Count Conditionally Formatted Cells (Dynamic Range). In this video, we create code that automatically counts all conditionally formatted cells in a range, regardless of the number of rows. This code allows the user to easily count conditionally formatted cells across multiple columns with different criteria for each. We use a Message Box and Else If to account for there being zero, one, or more conditionally formatted cells in our count.
Data used in this video:
gsociology.icaap.org/datauplo...
This is a modification of code from:
www.excelsirji.com/vba-code-c...
Code:
Sub count_cond_cells()
Dim rng As Range
Dim rngCell As Range
Dim row_count As Integer
Dim cond_count As Integer
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
ws.Activate
row_count = WorksheetFunction.CountA(Range("A1", Range("A1").End(xlDown)))
cond_count = 0
Set rng = ws.Range("D2:J" & row_count)
For Each rngCell In rng
If Cells(rngCell.Row, rngCell.Column).DisplayFormat. _
Interior.Color = RGB(255, 199, 206) Then
cond_count = cond_count + 1
End If
Next
If cond_count = 0 Then
MsgBox "There are no conditionally formatted cells."
ElseIf cond_count = 1 Then
MsgBox "There is 1 conditionally formatted cell."
Else
MsgBox "There are " & cond_count & " conditionally formatted cells."
End If
End Sub
#ExcelVBA #ExcelMacro

Опубликовано:

 

2 мар 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 11   
@robdc4829
@robdc4829 Год назад
I would rather have the total red cells show up in a cell versus a message. That said, this is the best video I've seen so far on the topic. All the other videos I've seen use a named range to use an old function. The seems to work with one column, but not with a table like he's done here.
@greggowaffles
@greggowaffles Год назад
Thank you for your feedback!
@greggowaffles
@greggowaffles Год назад
Just made a similar video where the total number of red cells show up at the end of each row. Excel VBA Macro: Count and List the Number of (Conditonally Formatted) Cells at the End of Each Row ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-PmdyyEFCJFU.html
@cgsmiddleafifa9340
@cgsmiddleafifa9340 Год назад
why my excel sheet not excepting VBA Macro code?
@greggowaffles
@greggowaffles Год назад
Hope you were able to get it working
@rashminsolanki8918
@rashminsolanki8918 2 года назад
Like one row has different conditionally colored cells... than end that cell one cell has count that how many cell ls of specific colored..
@greggowaffles
@greggowaffles Год назад
I can make a video on this topic
@greggowaffles
@greggowaffles Год назад
Just made a video on this! Excel VBA Macro: Count and List the Number of (Conditonally Formatted) Cells at the End of Each Row ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-PmdyyEFCJFU.html
@rashminsolanki8918
@rashminsolanki8918 2 года назад
I want to put counting conditionally colored cell like a formula...
@greggowaffles
@greggowaffles Год назад
Do you have a specific example?
@jozefnagels8443
@jozefnagels8443 9 месяцев назад
not very usefull if the value is not in a cell
Далее
How to get the Last Row in VBA(The Right Way!)
15:41
Просмотров 152 тыс.
Envy recreating this new trend ✨ #shorts
00:14
Просмотров 2,5 млн
SUM and COUNT by Cell Colour in Excel -- WITHOUT VBA!
16:32
Count colored cells in excel - Without VBA
9:42
Просмотров 46 тыс.
Excel Count Conditional Formatting Colours
9:23
Просмотров 13 тыс.
Count by Cell Colour - Excel VBA Function
4:54
Просмотров 25 тыс.