Excel VBA Macro: Count and List the Number of (Conditonally Formatted) Cells at the End of Each Row

Excel VBA Macro: Count and List the Number of (Conditonally Formatted) Cells at the End of Each Row
💥Subscribe: / @greggowaffles
This is a modification of code from:
www.excelsirji.com/vba-code-c...
Code:
Sub list_cond_cells_per_row()
Dim rng As Range
Dim rngCell As Range
Dim row_count As Integer
Dim col_count As Integer
Dim cond_count As Integer
Dim i As Integer
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
ws.Activate
row_count = WorksheetFunction.CountA(Range("A1", Range("A1").End(xlDown)))
col_count = WorksheetFunction.CountA(Range("A1", Range("A1").End(xlToRight)))
For i = 2 To row_count
Set rng = ws.Range(Cells(i, 1), Cells(i, col_count))
cond_count = 0
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
ws.Cells(i, col_count + 1) = cond_count
Next i
End Sub
#ExcelVBA #ExcelMacro

Пікірлер: 3

  • @kameya1104
    @kameya1104 Жыл бұрын

    I used lo do for loop for this kind of procedure, but now I prefer to use Do Until... i.e. Do Until Range("A" & i)="", then eliminate one extra variable like row_count.

  • @greggowaffles

    @greggowaffles

    Жыл бұрын

    Thanks for sharing that!!

  • @coolvideos4562
    @coolvideos45626 ай бұрын

    I have 1 year data but how to Filter one month data automatically Using VBA paste to new sheet