Numbering items in a table

Ethvia

Board Regular
Joined
Mar 10, 2009
Messages
63
Hi, I'm trying to number items in a table using a repeating range. For instance if I have 100 items in a table, I want to do a make table query to take those items and then number them 1-10 repeating (so when I get to the 11th item it's starts over numbering 1-10, the same when it gets to the 21st item). In the end, for the sake of this example, I would have 10 items assigned #1, 10 items assigned #2, etc.

I've played around trying to do this multiple ways and aren't having much luck. Does anyone have a suggestion of how to do this?

thanks!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It can be done like this.


Book1
AB
1namevalue
2A1
3B1
4C1
5A1
6B1
7C1
8A1
9B1
10C1
11A1
12B2
13C2
14A2
15B2
Blad13
Cell Formulas
RangeFormula
B2=INT((ROW()-2)/10)+1
 
Last edited:
Upvote 0
If you are trying to get {1,2,3,4,5,6,7,8,9,10,1,2,.......}

Code:
=MOD(ROW(A1)-1,10)+1
 
Upvote 0
It can be done like this.



Worksheet Formulas
CellFormula
B2=INT((ROW()-2)/10)+1

<tbody>
</tbody>

<tbody>
</tbody>

thanks for the response, but I'm trying to do this on a table in MS Access, not Excel. Or am I not understanding what you're writing?
 
Upvote 0
Thanks Ahoy, but I'm trying to accomplish this in MS Access.

What you're saying is correct, I want 1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,etc.... but I'm trying to add it as a field based off of an existing table via a query
 
Upvote 0
No, it is an excel solution.

Sorry I don't read enough, that you posted it in the access group.
 
Upvote 0
No expression will do what you want in a make table query because the record does not exist when an expression would need to use it. You could probably run an update query on your new table using the expression given by Ethvia, using an auto number field in your new table. You would substitute Row() with the auto number field name. The rest of the expression is common stuff.
In code, you could also create a recordset based on the table, then loop through it and set the field value to what the expression returns. That's a bit more complicated though.
 
Upvote 0

Forum statistics

Threads
1,221,852
Messages
6,162,431
Members
451,765
Latest member
craigvan888

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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