Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default two numbers need to show each number in the range btw them

i have two columns
5 9
15 19
20 29
i need for each row to show the numbers in the range
5
6
7
8
9
15
16
..
..
pls help

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default two numbers need to show each number in the range btw them

this worked ok for me.

Option Explicit
Sub testme01()

Dim CurWks As Worksheet
Dim NewWks As Worksheet
Dim myCell As Range
Dim myRng As Range
Dim oRow As Long
Dim HowMany As Long

Set CurWks = Worksheets("sheet1")
Set NewWks = Worksheets.Add

With CurWks
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

oRow = 1
For Each myCell In myRng.Cells
HowMany = myCell.Offset(0, 1).Value - myCell.Value + 1
With NewWks.Cells(oRow, "A").Resize(HowMany, 1)
.Formula = "=row(a1)-1 +" & myCell.Value
.Value = .Value
End With
oRow = oRow + HowMany
Next myCell

End Sub



If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

arsovat wrote:

i have two columns
5 9
15 19
20 29
i need for each row to show the numbers in the range
5
6
7
8
9
15
16
.
.
pls help


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default two numbers need to show each number in the range btw them

Thanks it's worked. Now i have to re-study macros and VB :)

"Dave Peterson" wrote:

this worked ok for me.

Option Explicit
Sub testme01()

Dim CurWks As Worksheet
Dim NewWks As Worksheet
Dim myCell As Range
Dim myRng As Range
Dim oRow As Long
Dim HowMany As Long

Set CurWks = Worksheets("sheet1")
Set NewWks = Worksheets.Add

With CurWks
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

oRow = 1
For Each myCell In myRng.Cells
HowMany = myCell.Offset(0, 1).Value - myCell.Value + 1
With NewWks.Cells(oRow, "A").Resize(HowMany, 1)
.Formula = "=row(a1)-1 +" & myCell.Value
.Value = .Value
End With
oRow = oRow + HowMany
Next myCell

End Sub



If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

arsovat wrote:

i have two columns
5 9
15 19
20 29
i need for each row to show the numbers in the range
5
6
7
8
9
15
16
.
.
pls help


--

Dave Peterson

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
How do I consoldiate a List of numbers to show each number once ? PPete Excel Discussion (Misc queries) 5 July 14th 06 06:04 PM
Avoid duplicate number entry when only start and stop numbers given. almk05 Excel Discussion (Misc queries) 1 March 26th 06 02:42 AM
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
Match Last Occurrence of two numbers and Count to Previous Occurence Sam via OfficeKB.com Excel Worksheet Functions 33 April 4th 05 02:17 PM
How to add one number to a range of numbers BatonRougeguy Excel Worksheet Functions 1 February 16th 05 06:47 AM


All times are GMT +1. The time now is 09:49 AM.

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"