ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   count resize range (https://www.excelbanter.com/excel-programming/438678-count-resize-range.html)

roster_jon[_2_]

count resize range
 
Hey,

I need a VBA code that count the number of times "cf" occurs in the 14 cells
to the left of every cell, including the cell, in a range and change the
bottom border line to a thick red line if the count exceeds 4.

What I'm trying to do is point out if someone has been scheduled "cf" more
than 4 times in the past 14 days.

Is this possible at all?

JLGWhiz[_2_]

count resize range
 
Since you did not specify the columns and rows, I used columns A thru O,
with O being the one that holds the criteria to identify which rows to count
the "cf" in. You can alter the macro to suit your actual sheet content.

Sub dk()
Dim lr As Long, sh As Worksheet
Dim rng As Range, fRng As Range, c As Range
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 15).End(xlUp).Row
Set rng = sh.Range("O2:O" & lr)
For Each c In rng
Set fRng = sh.Range("A" & c.Row & ":O" & c.Row)
If WorksheetFunction.CountIf(fRng, "cf") 4 Then
With fRng.Borders(xlEdgeBottom)
.LineStyle = Solid
.Weight = xlThick
.ColorIndex = 3
End With
End If
Next
End Sub



"roster_jon" wrote in message
...
Hey,

I need a VBA code that count the number of times "cf" occurs in the 14
cells
to the left of every cell, including the cell, in a range and change the
bottom border line to a thick red line if the count exceeds 4.

What I'm trying to do is point out if someone has been scheduled "cf" more
than 4 times in the past 14 days.

Is this possible at all?





All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com