View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Modify to write results into B2 down instead of msgbox

Since I authored the sub ( Thanks for the MISSING acknowledgment and
thanks ) I have sent you a file with one macro showing how to indicate the
missing and another macro inserting the missing.
Sub findmissingnumbersinlist()
mc = 1 'for col A
Columns(mc + 1).ClearContents
For i = 2 To Cells(Rows.Count, mc).End(xlUp).Row - 1
If Cells(i + 1, mc) < Cells(i, mc) + 1 Then
'MsgBox "Missing " & Cells(i, mc) + 1 & " at row " & i + 1
Cells(i + 1, mc + 1) = Cells(i, mc) + 1
End If
Next i
End Sub
Sub insertmissing()
mc = 1 'for col A
For i = 2 To Cells(Rows.Count, mc).End(xlUp).Row - 1
If Cells(i + 1, mc) < Cells(i, mc) + 1 Then
Rows(i + 1).Insert
Cells(i + 1, mc) = Cells(i, mc) + 1
End If
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Max" wrote in message
...
For the sub below, instead of msgbox, I would like to write
all results into say, B2 down on the sheet. How? Thanks.

Sub findmissingnumbersinlist()
mc = 1 'for col A
For i = 2 To Cells(Rows.Count, mc).End(xlUp).Row - 1
If Cells(i + 1, mc) < Cells(i, mc) + 1 Then
MsgBox "Missing " & Cells(i, mc) + 1 & " at row " & i + 1
End If
Next i
End Sub