Extracting missing numbers or dates

DRSteele

Well-known Member
Joined
Mar 31, 2015
Messages
2,640
Office Version
  1. 365
Platform
  1. Windows
I watched this video and modified the formulas. This will extract the missing values from between the minimum and maximum in the range (sorted or not) into either a single cell or a range of cells. Function TEXTJOIN requires Excel 2016, I think.

Is there a superior method?

https://www.youtube.com/watch?v=_jel_Otcgds

ABCDE
1Missing DatesMissing Numbers
2Nov 26/17, Dec 01/17, Dec 05/17, Dec 10/1743065, 43070, 43074, 43079
3DateNumber11/26/201743065
411/24/20174306312/1/201743070
511/25/20174306412/5/201743074
611/27/20174306612/10/201743079
711/28/201743067#NUM!#NUM!
811/29/201743068#NUM!#NUM!
911/30/201743069copy on downwardscopy on downwards
1012/2/201743071
1112/3/201743072
1212/4/201743073
1312/6/201743075
1412/7/201743076
1512/8/201743077
1612/9/201743078
1712/11/201743080
1812/12/201743081
1912/13/201743082
2012/14/201743083
2112/15/201743084
2212/16/201743085
2312/17/201743086

<tbody>
</tbody>
Sheet44

Worksheet Formulas
CellFormula
E3=D3

<tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
D2{=TEXTJOIN(", ",1,TEXT(IF(ISNA(MATCH(ROW(INDIRECT(MIN($A$4:$A$23)&":"&MAX($A$4:$A$23))),$A$4:$A$23,0)),ROW(INDIRECT(MIN($A$4:$A$23)&":"&MAX($A$4:$A$23))),""),"MMM dd/YY"))}
E2{=TEXTJOIN(", ",1,IF(ISNA(MATCH(ROW(INDIRECT(MIN($A$4:$A$23)&":"&MAX($A$4:$A$23))),$A$4:$A$23,0)),ROW(INDIRECT(MIN($A$4:$A$23)&":"&MAX($A$4:$A$23))),""))}
D3{=SMALL(IF(ISNA(MATCH(ROW(INDIRECT(MIN($A$4:$A$23)&":"&MAX($A$4:$A$23))),$A$4:$A$23,0)),ROW(INDIRECT(MIN($A$4:$A$23)&":"&MAX($A$4:$A$23)))),ROWS($A$4:A4))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
If your open to a VBA method, then try this:-

NB:- Your actual dates assumed to start "A4", Results start "D4".

Code:
[COLOR="Navy"]Sub[/COLOR] MG25Nov35
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] MinDt [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] MaxDt [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Temp [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] K [COLOR="Navy"]As[/COLOR] Variant, p [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range("A4", Range("A" & Rows.Count).End(xlUp))
MinDt = Application.Min(Rng): MaxDt = Application.Max(Rng)
c = 3
ReDim nray(MinDt To MaxDt) [COLOR="Navy"]As[/COLOR] Boolean
    [COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
        .CompareMode = vbTextCompare
  
        [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng: .Item(Dn.Value) = Dn.Offset(, 1): [COLOR="Navy"]Next[/COLOR]
            [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] K [COLOR="Navy"]In[/COLOR] .keys: nray(CDbl(DateValue(K))) = True: [COLOR="Navy"]Next[/COLOR] K
                [COLOR="Navy"]For[/COLOR] n = MinDt To MaxDt
                    [COLOR="Navy"]If[/COLOR] nray(n) [COLOR="Navy"]Then[/COLOR]
                        Temp = .Item(n)
                        p = 0
                    [COLOR="Navy"]End[/COLOR] If
                        [COLOR="Navy"]If[/COLOR] Not nray(n) [COLOR="Navy"]Then[/COLOR]
                            c = c + 1
                            p = p + 1
                            Cells(c, "D") = CDate(n)
                            Cells(c, "E") = Temp + p
                        [COLOR="Navy"]End[/COLOR] If
                [COLOR="Navy"]Next[/COLOR] n
    [COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Thanks tons, Mick. Very helpful.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,946
Members
449,480
Latest member
yesitisasport

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