Hello friends. Please help ! COUNTIF formula ?
Solved/Closed
realest25
-
Jun 7, 2022 at 03:31 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jun 13, 2022 at 11:58 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jun 13, 2022 at 11:58 AM
Related:
- Hello friends. Please help ! COUNTIF formula ?
- Logitech formula vibration feedback wheel driver - Download - Drivers
- Excel grade formula - Guide
- Date formula in excel dd/mm/yyyy - Guide
- Number to words in excel formula - Guide
- Credit summation formula - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
552
Jun 9, 2022 at 12:00 PM
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).