Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Insert Missing Numbers

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--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert Missing Numbers


This is crude but will do it for you!

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


ryguy7272;523377 Wrote:
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--

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



--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=143638

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Insert Missing Numbers

That works great!!
Thanks,
Ryan--

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


"Simon Lloyd" wrote:


This is crude but will do it for you!

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


ryguy7272;523377 Wrote:
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--

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



--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=143638


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert Missing Numbers


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

Glad you're sorted!

ryguy7272;523493 Wrote:
That works great!!
Thanks,
Ryan--

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


"Simon Lloyd" wrote:


This is crude but will do it for you!

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


ryguy7272;523377 Wrote:
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--

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



--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' ('The Code Cage - Microsoft Office Help -

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

------------------------------------------------------------------------
Simon Lloyd's Profile: 'The Code Cage Forums - View Profile: Simon

Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread: 'Insert Missing Numbers - The Code Cage Forums'

(http://www.thecodecage.com/forumz/sh...d.php?t=143638)




--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=143638

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Insert Missing Numbers

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
---------------
Jacob Skaria


"Simon Lloyd" wrote:


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

Glad you're sorted!

ryguy7272;523493 Wrote:
That works great!!
Thanks,
Ryan--

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


"Simon Lloyd" wrote:


This is crude but will do it for you!

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


ryguy7272;523377 Wrote:
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--

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


--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' ('The Code Cage - Microsoft Office Help -

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

------------------------------------------------------------------------
Simon Lloyd's Profile: 'The Code Cage Forums - View Profile: Simon

Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread: 'Insert Missing Numbers - The Code Cage Forums'

(http://www.thecodecage.com/forumz/sh...d.php?t=143638)




--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=143638




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert Missing Numbers


Errrrmmmm!, BRILLIANT! :)

Jacob Skaria;523549 Wrote:
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
---------------
Jacob Skaria


"Simon Lloyd" wrote:


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

Glad you're sorted!

ryguy7272;523493 Wrote:
That works great!!
Thanks,
Ryan--

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


"Simon Lloyd" wrote:


This is crude but will do it for you!

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


ryguy7272;523377 Wrote:
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--

--
Ryan---
If this information was helpful, please indicate this by

clicking
''Yes''.


--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' ('The Code Cage - Microsoft Office Help -
Microsoft Office Discussion' ('The Code Cage - Microsoft Office

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


------------------------------------------------------------------------
Simon Lloyd's Profile: 'The Code Cage Forums - View Profile:

Simon
Lloyd' ('The Code Cage Forums - View Profile: Simon Lloyd'

(http://www.thecodecage.com/forumz/member.php?userid=1))
View this thread: 'Insert Missing Numbers - The Code Cage Forums'
('Insert Missing Numbers - The Code Cage Forums'

(http://www.thecodecage.com/forumz/sh....php?t=143638))




--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' ('The Code Cage - Microsoft Office Help -

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

------------------------------------------------------------------------
Simon Lloyd's Profile: 'The Code Cage Forums - View Profile: Simon

Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread: 'Insert Missing Numbers - The Code Cage Forums'

(http://www.thecodecage.com/forumz/sh...d.php?t=143638)




--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=143638

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
Insert Name missing from Toolbar [email protected] Excel Discussion (Misc queries) 2 April 18th 09 01:56 PM
to find missing serial numbers in randomly generated numbers B.H. Hadi Excel Worksheet Functions 2 December 1st 05 10:56 PM
View & Insert missing from menu bar!?!?! trixiebme Excel Discussion (Misc queries) 5 May 12th 05 03:49 PM
What variable do you insert for X-cel if there is missing data? Iop.kcl New Users to Excel 1 March 22nd 05 05:00 PM
Macro To insert missing data lshavit[_2_] Excel Programming 0 October 29th 04 01:35 PM


All times are GMT +1. The time now is 07:52 PM.

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

About Us

"It's about Microsoft Excel"