LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default find and insert missing values

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/



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Name missing from Toolbar [email protected] Excel Discussion (Misc queries) 2 April 18th 09 01:56 PM
How to find missing values while reconciling files? Piotr (Peter)[_2_] Excel Discussion (Misc queries) 4 January 25th 09 07:29 PM
Find missing values in a series petermcwerner Excel Worksheet Functions 10 January 4th 07 08:35 AM
insert row into worksheet when date missing [email protected] Excel Worksheet Functions 0 November 9th 06 09:10 PM
Excel Compare values in columns & display missing values in a new cpetta Excel Discussion (Misc queries) 1 April 2nd 05 05:51 AM


All times are GMT +1. The time now is 08:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"