how to count how many unique acc i have in a month

AYSHANA

Board Regular
Joined
Oct 16, 2021
Messages
90
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
good day

i want to count how many unique ACC i have in month

Book2
BCDEFGHIJKLMNOPQ
1ACC no.UNIT ALLOCATED IN SYSTEM2023
2T78891215-02-23 9:50FEBMARAPRMAYJUNJULAUGSEPOCTNOVDECTOTAL
3W47627215-02-23 14:44
4W47627215-02-23 14:44
5T78771614-02-23 17:38
6T78268916-02-23 10:56
7W47502315-02-23 23:51
8H43947217-02-23 8:58
9S46105419-02-23 9:40
10S46105419-02-23 9:40
11S46105401-04-23 8:00
12S46011318-02-23 19:44
13S46011318-02-23 19:44
14S46011318-02-23 19:44
15S46011301-0-2023 02:35
Sheet2
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Thanks, that is much clearer. :)

Yes, it is a reasonably similar formula but a bit simpler since it doesn't have to do any 'unique' assessment.
Note that I have changed the data in row 5 so that there is at least a count for March.

23 03 05.xlsm
GJQRS
1CRA Receive Date TimeWorkbench received to Result
214-02-23 16:4731
314-02-23 13:54302023
414-02-23 04:3537
514-03-23 20:19233FEBMARAPR
614-02-23 16:0531210
714-02-23 14:0136
814-02-23 14:1031
914-02-23 10:32110
1014-02-23 02:3438
1114-02-23 12:3930
1214-02-23 16:3639
1314-02-23 20:4439
1414-02-23 05:1942
1514-02-23 14:1864
Count >=60
Cell Formulas
RangeFormula
Q6:S6Q6=SUMPRODUCT(--(TEXT($G2:$G15,"mmmyyyy")=Q5&$R3),--($J2:$J15>=60))
 
Upvote 1
i want to add two more criteria
.. but you only described one. ;)
I assume that the second one is that we have to take account of the values in column B matching the values in column O.
Speaking of column O, I also assume that your value in O7 was a typo and that value should be what I have in my O7 below?

23 03 05.xlsm
BGJOPQR
1OrdersCRA Receive Date TimeWorkbench received to Result
2BGRPS14-02-23 16:4731
3BGRPS14-02-23 13:54302023
4BGRPS14-02-23 04:3537
5BGRP14-02-23 18:5415JANFEBMAR
6BGRPS14-02-23 20:1933BGRPS10
7BGRPS14-02-23 16:0531%XM20
8BGRPS14-02-23 14:01#ERROR
9BGRPS14-02-23 14:1031
10%XM14-02-23 06:0761
11%XM14-02-23 16:5762
12BGRP14-02-23 01:4553
13BGRPS14-02-23 10:32110
14%XM14-02-23 12:5730
1514-02-23 14:1864
Count >=60 (2)
Cell Formulas
RangeFormula
Q6:R7Q6=SUMPRODUCT(--($B$2:$B$15=$O6),--(TEXT($G$2:$G$15,"mmmyyyy")=Q$5&$R$3),--($J$2:$J$15>=60),--(ISNUMBER($J$2:$J$15)))
 
Upvote 1
i have used this formula
but i dont know what wrong i did

=SUM(--(FREQUENCY(IF(YEAR($C2)&"-"&MONTH($C2)=YEAR($C$2:$C$200)&"-"&MONTH($C$2:$C$200), $B$2:$B$300, ""), ($B$2:$D$300))>0))
 
Upvote 0
Try this. I added JAN before FEB on my sheet.

VBA Code:
Sub accCount()
Dim myWbk As Workbook, mySht As Worksheet, accRng As Range, allRng As Range, myRng As Range
Dim i As Long, x As Long, y As Long
Dim accNbrJan, accNbrFeb, accNbrMar, accNbrApr, accNbrMay, accNbrJun, accNbrJul
Dim accNbrAug, accNbrSep, accNbrOct, accNbrNov, accNbrDec
Set myWbk = ThisWorkbook: Set mySht = myWbk.Worksheets("Sheet2")
Set accRng = mySht.Range(Cells(2, 1), Cells(mySht.UsedRange.Rows.Count, 1))
Set allRng = mySht.Range(Cells(2, 2), Cells(mySht.UsedRange.Rows.Count, 2))

For i = 2 To mySht.UsedRange.Rows.Count
    Select Case Month(mySht.Cells(i, 2))
        Case 1
            accNbrJan = accNbrJan + 1
        Case 2
            accNbrFeb = accNbrFeb + 1
        Case 3
            accNbrMar = accNbrMar + 1
        Case 4
            accNbrApr = accNbrApr + 1
        Case 5
            accNbrMay = accNbrMay + 1
        Case 6
            accNbrJun = accNbrJun + 1
        Case 7
            accNbrJul = accNbrJul + 1
        Case 8
            accNbrAug = accNbrAug + 1
        Case 9
            accNbrSep = accNbrSep + 1
        Case 10
            accNbrOct = accNbrOct + 1
        Case 11
            accNbrNov = accNbrNov + 1
        Case 12
            accNbrDec = accNbrDec + 1
        Case Else
            MsgBox "Not a valid date.", vbOKOnly, "Type Mismatch"
            Exit Sub
    End Select
Next i

mySht.Cells(3, 3) = accNbrJan: mySht.Cells(3, 4) = accNbrFeb: mySht.Cells(3, 5) = accNbrMar
mySht.Cells(3, 6) = accNbrApr: mySht.Cells(3, 7) = accNbrMay: mySht.Cells(3, 8) = accNbrJun
mySht.Cells(3, 9) = accNbrJul: mySht.Cells(3, 10) = accNbrAug: mySht.Cells(3, 11) = accNbrSep
mySht.Cells(3, 12) = accNbrOct: mySht.Cells(3, 13) = accNbrNov: mySht.Cells(3, 14) = accNbrDec


End Sub
 
Upvote 0
it is not working
Edited for incorrect dates:
VBA Code:
Sub accCount()
Dim myWbk As Workbook, mySht As Worksheet, accRng As Range, allRng As Range, myRng As Range
Dim i As Long, x As Long, y As Long
Dim accNbrJan, accNbrFeb, accNbrMar, accNbrApr, accNbrMay, accNbrJun, accNbrJul
Dim accNbrAug, accNbrSep, accNbrOct, accNbrNov, accNbrDec
Set myWbk = ThisWorkbook: Set mySht = myWbk.Worksheets("Sheet2")
Set accRng = mySht.Range(Cells(2, 1), Cells(mySht.UsedRange.Rows.Count, 1))
Set allRng = mySht.Range(Cells(2, 2), Cells(mySht.UsedRange.Rows.Count, 2))
On Error GoTo Err
For i = 2 To mySht.UsedRange.Rows.Count
    Select Case Month(mySht.Cells(i, 2))
        Case 1
            accNbrJan = accNbrJan + 1
        Case 2
            accNbrFeb = accNbrFeb + 1
        Case 3
            accNbrMar = accNbrMar + 1
        Case 4
            accNbrApr = accNbrApr + 1
        Case 5
            accNbrMay = accNbrMay + 1
        Case 6
            accNbrJun = accNbrJun + 1
        Case 7
            accNbrJul = accNbrJul + 1
        Case 8
            accNbrAug = accNbrAug + 1
        Case 9
            accNbrSep = accNbrSep + 1
        Case 10
            accNbrOct = accNbrOct + 1
        Case 11
            accNbrNov = accNbrNov + 1
        Case 12
            accNbrDec = accNbrDec + 1
    End Select
Next i

mySht.Cells(3, 3) = accNbrJan: mySht.Cells(3, 4) = accNbrFeb: mySht.Cells(3, 5) = accNbrMar
mySht.Cells(3, 6) = accNbrApr: mySht.Cells(3, 7) = accNbrMay: mySht.Cells(3, 8) = accNbrJun
mySht.Cells(3, 9) = accNbrJul: mySht.Cells(3, 10) = accNbrAug: mySht.Cells(3, 11) = accNbrSep
mySht.Cells(3, 12) = accNbrOct: mySht.Cells(3, 13) = accNbrNov: mySht.Cells(3, 14) = accNbrDec

Err:
    MsgBox "Check for invalid date.", vbOKOnly, "Type Mismatch"

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,795
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top