I need help figuring out how to write CountIf within a subroutine that returns a value rather than inserts a formula into a cell.
I'm pretty sure I have to use WorksheetFunction.CountIf but can't wrap my mind on how to use it and make it flow (For Each cell in Range).
Also, not sure if I need to Dim ranges for Arg1, Arg2 if I want to use relative reference.
So, I think it should go something like this but obviously I'm not sure.
Sub CountIf_Last_30_Days()
Dim LastRow As Long
'Dim c As Range, d As Range?
Application.ScreenUpdating = False
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
'WorksheetFunction.CountIf(Range(???
Application.ScreenUpdating = True
End Sub
Not sure if I've explained this well enough or if you'll be able to figure out what I'm trying to accomplish using the example provided, so, I'll answer specific questions.
Thanks in advance to anyone who is willing to take a crack at it
I'm pretty sure I have to use WorksheetFunction.CountIf but can't wrap my mind on how to use it and make it flow (For Each cell in Range).
Also, not sure if I need to Dim ranges for Arg1, Arg2 if I want to use relative reference.
So, I think it should go something like this but obviously I'm not sure.
Sub CountIf_Last_30_Days()
Dim LastRow As Long
'Dim c As Range, d As Range?
Application.ScreenUpdating = False
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
'WorksheetFunction.CountIf(Range(???
Application.ScreenUpdating = True
End Sub
Not sure if I've explained this well enough or if you'll be able to figure out what I'm trying to accomplish using the example provided, so, I'll answer specific questions.
Thanks in advance to anyone who is willing to take a crack at it
Cell Formulas | ||
---|---|---|
Range | Formula | |
H32:H61 | H32 | =COUNTIF(B2:F31,$H$1) |
I32:I61 | I32 | =COUNTIF(B2:F31,$I$1) |
J32:J61 | J32 | =COUNTIF(B2:F31,$J$1) |
K32:K61 | K32 | =COUNTIF(B2:F31,$K$1) |
L32:L61 | L32 | =COUNTIF(B2:F31,$L$1) |
M32:M61 | M32 | =COUNTIF(B2:F31,$M$1) |
N32:N61 | N32 | =COUNTIF(B2:F31,$N$1) |
O32:O61 | O32 | =COUNTIF(B2:F31,$O$1) |
P32:P61 | P32 | =COUNTIF(B2:F31,$P$1) |
Q32:Q61 | Q32 | =COUNTIF(B2:F31,$Q$1) |
R32:R61 | R32 | =COUNTIF(B2:F31,$R$1) |
S32:S61 | S32 | =COUNTIF(B2:F31,$S$1) |
T32:T61 | T32 | =COUNTIF(B2:F31,$T$1) |
U32:U61 | U32 | =COUNTIF(B2:F31,$U$1) |
V32:V61 | V32 | =COUNTIF(B2:F31,$V$1) |
W32:W61 | W32 | =COUNTIF(B2:F31,$W$1) |
X32:X61 | X32 | =COUNTIF(B2:F31,$X$1) |
Y32:Y61 | Y32 | =COUNTIF(B2:F31,$Y$1) |
Z32:Z61 | Z32 | =COUNTIF(B2:F31,$Z$1) |
AA32:AA61 | AA32 | =COUNTIF(B2:F31,$AA$1) |
AB32:AB61 | AB32 | =COUNTIF(B2:F31,$AB$1) |
AC32:AC61 | AC32 | =COUNTIF(B2:F31,$AC$1) |
AD32:AD61 | AD32 | =COUNTIF(B2:F31,$AD$1) |
AE32:AE61 | AE32 | =COUNTIF(B2:F31,$AE$1) |
AF32:AF61 | AF32 | =COUNTIF(B2:F31,$AF$1) |
AG32:AG61 | AG32 | =COUNTIF(B2:F31,$AG$1) |