Insert Missing Numbers

R

ryguy7272

I used to have a macro that inserted rows, between numbers, and inserted the
missing numbers as it looped down the list. Can't find it now...

Basically, if I have the following setup:
A1 = 1
A2 = 8
A3 = 10

I want to see:
A1 = 1
A2 = 2
A3 = 3
....
A9 = 9
A10 = 10

How can I do this?

Thanks,
Ryan--
 
S

Simon Lloyd

This is crude but will do it for you

Code
-------------------
Dim Rng As Range, MyCell As Rang
Dim MyNum As Double, i As Lon
Set Rng = Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row
With Rn
MyNum = Application.WorksheetFunction.Large(Rng, 1
End Wit
For i = MyNum To 1 Step -
Cells(i, 1) = MyNu
MyNum = MyNum -
Next
-------------------

ryguy7272;523377 said:
I used to have a macro that inserted rows, between numbers, and inserte
th
missing numbers as it looped down the list. Can't find it now..

Basically, if I have the following setup
A1 =
A2 =
A3 = 1

I want to see
A1 =
A2 =
A3 =
...
A9 =
A10 = 1

How can I do this

Thanks
Ryan-

-
Ryan--
If this information was helpful, please indicate this by clickin
''Yes''

--
Simon Lloy

Regards
Simon Lloy
'Microsoft Office Help' (http://www.thecodecage.com
 
S

Simon Lloyd

It's not brilliant, it simply finds the largest number in the rang
using a worksheet function and then numbers backwards from that cell

Glad you're sorted

ryguy7272;523493 said:
That works great!
Thanks
Ryan-

-
Ryan--
If this information was helpful, please indicate this by clickin
''Yes''






Microsoft Office Discussion' (http://www.thecodecage.com)

--
Simon Lloy

Regards
Simon Lloy
'Microsoft Office Help' (http://www.thecodecage.com
 
J

Jacob Skaria

Ryan/Simon

You can avoid that looping using this one liner....With data starting from
cell A1

Range("A1").DataSeries Rowcol:=xlColumns, Type:=xlLinear, _
Step:=1, Stop:=WorksheetFunction.Max(Columns(1))

If this post helps click Yes
 
S

Simon Lloyd

Errrrmmmm!, BRILLIANT! :
Ryan/Simo

You can avoid that looping using this one liner....With data startin
fro
cell A

Range("A1").DataSeries Rowcol:=xlColumns, Type:=xlLinear,
Step:=1, Stop:=WorksheetFunction.Max(Columns(1)

If this post helps click Ye
--------------
Jacob Skari







Microsoft Office Discussion' (http://www.thecodecage.com)

--
Simon Lloy

Regards
Simon Lloy
'Microsoft Office Help' (http://www.thecodecage.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top