Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Checking Sequential numbering

This is something I can't quite figure out.
I have two columns that I need to check the left column to make sure that
all numbers exist. If all do not exist then either add blank cells or the
missing numbers.
EX: before
A B
1 70001 20
2 70002 30
3 70005 20
Ex: after
A B
1 70001 20
2 70002 30
3 ; or 70003
4 ; or 70004
5 70005 20

Is this even possible?
I would be most appreciative for your help.
Any example would be helpful.
--
Bob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checking Sequential numbering


Try this

Sub Test()
For N = Cells(65536, 1).End(xlUp).Row To 2 Step -1
If Cells(N, 1) - 1 < Cells(N - 1, 1) Then
Rows(N).Insert
Cells(N, 1) = Cells(N + 1, 1) - 1
N = N + 1
End If
Next N
End Sub

The code starts at the bottom and works upwards and should deal with
gaps of one or more than one number.


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=548335

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Checking Sequential numbering

Bob

one way:

Sub InsertRows()

Dim LastRow As Long
Dim i As Long
Dim RowDifference As Long

LastRow = Range("A65536").End(xlUp).Row

For i = LastRow To 2 Step -1
RowDifference = Range("A" & i).Value - Range("A" & i - 1).Value
If RowDifference 1 Then
Range("A" & i & ":A" & i + RowDifference - 2).EntireRow.Insert
End If
Next 'i

End Sub

Regards

Trevor


"Bob" wrote in message
...
This is something I can't quite figure out.
I have two columns that I need to check the left column to make sure that
all numbers exist. If all do not exist then either add blank cells or the
missing numbers.
EX: before
A B
1 70001 20
2 70002 30
3 70005 20
Ex: after
A B
1 70001 20
2 70002 30
3 ; or 70003
4 ; or 70004
5 70005 20

Is this even possible?
I would be most appreciative for your help.
Any example would be helpful.
--
Bob



Reply
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
sequential numbering majestyk[_2_] Excel Worksheet Functions 0 February 13th 09 03:24 PM
Sequential numbering by 6 BattyKat Excel Discussion (Misc queries) 4 July 9th 08 03:11 PM
Sequential numbering Scott Hemphill Excel Discussion (Misc queries) 2 July 24th 07 05:24 PM
PO with sequential numbering with start / end numbering [email protected] Excel Discussion (Misc queries) 1 April 24th 07 03:38 PM
Sequential numbering REELAXER Excel Worksheet Functions 1 June 30th 05 12:25 AM


All times are GMT +1. The time now is 10:34 AM.

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"