Converting a range of numbers to individual numbers

  • Thread starter Thread starter Smythe32
  • Start date Start date
S

Smythe32

Hi,

I was hoping someone could help me out here with some code. I need to
take a starting number and an ending number and produce a list of all
the numbers in between.

Ex:
Start_Num End_Num
2345611000 2345611005
5856378700 5855378703
7162251601 7162251601

I would like these to append to another table. For example once the
above are broken out, the following would append to a current table.

2345611000
2345611001
2345611002
2345611003
2345611004
2345611005
5856378700
5856378701
5856378702
5856378703
7162251601

Thanks in advance.
 
See the MakeData() function at the end of this article:
http://allenbrowne.com/ser-39.html

You could change the first line:
Function MakeData()
to:
Function MakeData(Start_Num As Long, End_Num As Long)
and the line:
For lng = 1 to conMaxRecords
to
For lng = Start_Num to End_Num

Change the table name, and call the function to add the records.
 
I was hoping someone could help me out here with some code. I need to
take a starting number and an ending number and produce a list of all
the numbers in between.

Ex:
Start_Num End_Num
2345611000 2345611005
5856378700 5855378703
7162251601 7162251601

I would like these to append to another table. For example once the
above are broken out, the following would append to a current table.

2345611000
2345611001
2345611002
2345611003
2345611004
2345611005
5856378700
5856378701
5856378702
5856378703
7162251601


If you aready have Allen's tblCount and the start/end values
are in table tblStartEnd, then you could do it all with a
query:

INSERT INTO anothertable
SELECT tblStartEnd.Start_Num + tblCount.CountID -1
FROM tblStartEnd, tblCount
WHERE tblStartEnd.Start_Num + tblCount.CountID - 1
<= tblStartEnd.End_Num
 
Back
Top