Find the highest value from range, multiple entry and adjacent cells date

Anbuselvam

Board Regular
Joined
May 10, 2017
Messages
97
Hi

In the excel sheet, I have the date in J8:J9999 and Invoice number in the Column K8:K9999.

Invoice number having 4 series as below,
1 to 1000
1001 to 4000
4001 to 5000
10000 to 15000

Invoice number entry will be like this
1&2&3
1005
1006&1007&1008
4004
4005&4006&4007

I used a formula in R4 to find the highest value from 4000 to 5000 is
=AGGREGATE(14,6,K8:K9999/(K8:K9999>=4001)/(K8:K9999<=5000),1)

My expected value in R4 is 4007 (highest value between 4000 to 5000) but it is showing 4004 because it is ignoring to take 4005&4006&4007 entry.

How do I change the formula to get the 4007 in cell R4?

Note: The entry from 4000 to 5000 will be the year of 2019 entries only. I don't know how to get the highest value from this year entry as well as multiple entries too.

Please suggest the formula

Thanks in advance

Sincerely Yours
Anbuselvam K
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi

In the excel sheet, I have the date in J8:J9999 and Invoice number in the Column K8:K9999.

Invoice number having 4 series as below,
1 to 1000
1001 to 4000
4001 to 5000
10000 to 15000

Invoice number entry will be like this
1&2&3
1005
1006&1007&1008
4004
4005&4006&4007

I used a formula in R4 to find the highest value from 4000 to 5000 is
=AGGREGATE(14,6,K8:K9999/(K8:K9999>=4001)/(K8:K9999<=5000),1)

My expected value in R4 is 4007 (highest value between 4000 to 5000) but it is showing 4004 because it is ignoring to take 4005&4006&4007 entry.

How do I change the formula to get the 4007 in cell R4?

Note: The entry from 4000 to 5000 will be the year of 2019 entries only. I don't know how to get the highest value from this year entry as well as multiple entries too.

Note:

The below formula also finding the highest values even with multiple entries like 12200&12201&12203. But, I need to find between 4001 to 5000 ranges.

Because this year invoice number starts with 4001 which is a lesser value than last year invoice number series like 12200 and so.

=AGGREGATE(14,6,--MID(SUBSTITUTE(K8:K10921,"&",REPT(" ",30)),{1,30,60,90,120},30),1)

Please suggest the formula

Thanks in advance

Sincerely Yours
Anbuselvam K
 
Upvote 0
Here is the UDF code
Code:
Function MaxSpecial(DateRng As Range, Year_ As Integer, NumRng As Range) As Long


Dim cel As Range
Dim T As Long, TA As Long


For Each cel In NumRng


    If Year(DateRng.Cells(T, 1)) = Year_ Then
    M = Split(cel, "&")
    
    For TA = 0 To UBound(M)
    MaxSpecial = WorksheetFunction.Max(MaxSpecial, 0 + M(TA))
    Next TA
    
    End If
T = T + 1
Next cel


End Function

To paste the code
Developer Tab --> Visual Basic
Insert --> Module
Then paste the code.
Close the widow.
Now UDF is available in function list.
For DateRng Select J8:J9999
For Year_ enter 2019 (Or required year)
For NumRng Select K8:K9999
 
Upvote 0
I have revised the code
Code:
Function MaxSpecial(DateRng As Range, Year_ As Integer, NumRng As Range) As Long


Dim cel As Range
Dim T As Long, TA As Long


T = 1
For Each cel In NumRng


    If Year(DateRng.Cells(T, 1)) = Year_ Then
    M = Split(cel, "&")
    
    For TA = 0 To UBound(M)
    MaxSpecial = WorksheetFunction.Max(MaxSpecial, 0 + M(TA))
    Next TA
    
    End If
T = T + 1
Next cel


End Function

In the file formula in K6 is very very slow. If not required delete this.
 
Upvote 0
Solution
Really Thanks Mr KVSM

it is working now.

Can you suggest an alternate formula for K6? if your time permits.

Actually, In K6 resulting the missing value of the invoice numbers.
 
Upvote 0
PHP:
=Anbuselvam 

Actually, In K6 resulting the missing value of the invoice numbers.
I did not understand . Explain in detail.


Our invoice will be like a serial number if I enter 4049&4050 and then 4052&4053 then K6 will reflect 4051. because I skipped or forgot to enter 4051.

I hope you understand.
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

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