Thread: Insert rows
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default Insert rows

Gareth

one way:

Sub InsertRows()
Dim LastRow As Long
Dim i As Long
Dim InsertCount As Long
Application.ScreenUpdating = False
InsertCount = 1
Do Until InsertCount = 0
InsertCount = 0
LastRow = Range("A65536").End(xlUp).Row
For i = LastRow To 3 Step -1
If Range("A" & i).Value < Range("A" & i - 1).Value + 1 Then
Range("A" & i).EntireRow.Insert
Range("A" & i) = Range("A" & i).Offset(1, 0).Value - 1
Range("A" & i).Offset(0, 1) = 0
InsertCount = 1
End If
Next 'i
Loop
Application.ScreenUpdating = True
End Sub

Regards

Trevor


"Gareth" wrote in message
...
I have 2 columns of data, A2:A? contains week numbers in ascending order

and
B2:B? contains orders received in that week.

I now have to put this date into a chart. This is no problem but there

are
some week numbers missing, want I want is a little macro to add in the
missing numbers and enter a 0 in colun B . For example:

Column A Column B
Week No. Orders
1 23
2 29
5 23
6 56
8 55


This should look like:

Column A Column B
Week No. Orders
1 23
2 29
3 0
4 0
5 23
6 56
7 0
8 55

Thaks in advance.

Gareth