Hello friends. Please help ! COUNTIF formula ?
Solved
realest25
-
Jun 7, 2022 at 03:31 PM
TrowaD
TrowaD
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Related:
- Hello friends. Please help ! COUNTIF formula ?
- Excel - Countif formula issue - How-To - Excel
- Countifs formula in excel with multiple sheets - Guide
- Countif formula in french - Guide
- COUNTIF Formula ✓ - Forum - Office Software
- How to count names in Excel: formula, using COUNTIF - Guide
1 reply
TrowaD
Jun 9, 2022 at 12:00 PM
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Jun 9, 2022 at 12:00 PM
Hi Realest25,
I can't think of (a) function(s) that can do that specific task, so I created one for you.
This is the code:
How to implement the code to use the custom function:
How to use the function:
=CountVal(B$3:B$12;"W") for B15
=CountVal(B$3:B$12;"D") for B16
=CountVal(B$3:B$12;"L") for B17
Drag these cells to the right and clear the results for columns C and E.
Best regards,
Trowa
I can't think of (a) function(s) that can do that specific task, so I created one for you.
This is the code:
Public Function CountVal(mRange As Range, mVal As String) As Integer Dim x As Integer For Each cell In mRange If cell.Value <> vbNullString Then x = x + 1 If cell.Value = mVal And x < 6 Then CountVal = CountVal + 1 End If Next cell End Function
How to implement the code to use the custom function:
- Open VBE: ALT+F11
- Go to the top menu's and click on Insert, then Module
- Place the above code in the big white field
- Close the VBE window
How to use the function:
=CountVal(B$3:B$12;"W") for B15
=CountVal(B$3:B$12;"D") for B16
=CountVal(B$3:B$12;"L") for B17
Drag these cells to the right and clear the results for columns C and E.
Best regards,
Trowa
Jun 10, 2022 at 04:19 PM
Jun 13, 2022 at 11:58 AM
Glad you figured out to replace the separator ";" (semicolon) into "," (comma).