Macro to show missing numbers, Excel 2003

jim101

Board Regular
Joined
Mar 22, 2005
Messages
110
I need a macro to check a column of numbers and show me the ones that are missing in a message box, so in the example below the macro would show 102,103,109 in the message box.
Thanks



<b>Excel 2003</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="text-align: center;;">Numbers</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">100</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;">101</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style=";">BP</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;">104</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;;">105</td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: right;;">106</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style=";">BP</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="text-align: right;;">107</td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="text-align: right;;">108</td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style="text-align: right;;">110</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br />
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Code:
Sub Missing()
Dim i As Long
Dim Max As Long
Dim Min As Long
Dim s As String
Max = WorksheetFunction.Max(Range("A:A"))
Min = WorksheetFunction.Min(Range("A:A"))
For i = Min + 1 To Max - 1
    If WorksheetFunction.CountIf(Range("A:A"), i) = 0 Then s = s & i & ","
Next i
MsgBox s

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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