Hello friends. Please help ! COUNTIF formula ?
Solved/Closed
realest25
-
7 Jun 2022 à 15:31
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 13 Jun 2022 à 11:58
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 13 Jun 2022 à 11:58
Related:
- Count f
- Logitech formula vibration feedback wheel driver - Download - Drivers
- Spreadsheet formula - Guide
- Grade formula in excel marksheet - Guide
- Credit summation formula - Guide
- Formula to calculate vat in excel - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
9 Jun 2022 à 12:00
9 Jun 2022 à 12:00
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
10 Jun 2022 à 16:19
13 Jun 2022 à 11:58
Glad you figured out to replace the separator ";" (semicolon) into "," (comma).