# Maccro to insert rows for missing numbers?

#### tonywatsonhelp

##### Well-known Member
HI Everyone,

OK so column A is supposed to be a list of numbers 1 to 7 repeated over and over
so: "1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7, and so on down column A

the problem is some of the numbers are missing for example
"1,2,3,4,5,6,7,1,3,4,5,6,7,1,2,3,5,6,7,1,2,4,5,6,7,1,2,3,4,5,6,7," so I need a macro that can look down column A and if it finds a number missing insert a row and add the missing number,
I'm totally lost could really do with some help here.

Thanks

Tony

### Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this:-

Code:
``````[COLOR="Navy"]Sub[/COLOR] MG09Jun21
[COLOR="Navy"]Dim[/COLOR] Lst [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] temp [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Lst = Range("A" & Rows.Count).End(xlUp).Row
[COLOR="Navy"]For[/COLOR] n = Lst To 2 [COLOR="Navy"]Step[/COLOR] -1
[COLOR="Navy"]With[/COLOR] Range("A" & n)
temp = .Value
temp = IIf(temp = 1, 7, temp - 1)
[COLOR="Navy"]If[/COLOR] Not .Offset(-1).Value = temp [COLOR="Navy"]Then[/COLOR]
.EntireRow.Insert
.Offset(-1).Value = temp
n = n + 1
[COLOR="Navy"]End[/COLOR] If

[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]``````
Regards Mick

Replies
35
Views
800
Replies
0
Views
207
Replies
2
Views
333
Replies
12
Views
440
Replies
4
Views
209

1,196,328
Messages
6,014,670
Members
441,834
Latest member
GHOSTOF309

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back