Debbie,
If you don't mind doing a sort on the range, maybe something like this?
Sub CallTheProcedure()
Call FindGaps(Range("A1:A13"))
End Sub
Sub FindGaps(rng As Range)
Dim c As Range
Dim lngCounter As Long
rng.Sort Key1:=rng(1, 1)
lngCounter = rng(1, 1).Value
For Each c In rng
If c.Value < lngCounter Then
c.Offset(0, 0).Resize(1, 2).Insert _
(xlShiftDown)
c.Offset(-1, 0).Value = lngCounter
End If
lngCounter = lngCounter + 1
Next c
Set c = Nothing
End Sub
--
HTH,
Dianne Butterworth
Here is a portion of my data set.
A B
244 2
243 2
241 2
240 3
239 1
238 1
235 4
233 5
232 5
226 3
225 3
224 3
223 2
How can I find the missing values in the serial list in Column A and
insert a row (and the missing value) where appropriate?
Thanks
Debbie
---
Message posted from http://www.ExcelForum.com/