simple list of sequential numbers

User avatar
stuck
Panoramic Lounger
Posts: 8267
Joined: 25 Jan 2010, 09:09
Location: retirement

simple list of sequential numbers

Post by stuck »

I'm sure I've done this before but I can't find the relevant document and my Googling hasn't helped...

I want to be able to put a starting number into one cell of a table and then have each subsequent cell increment that number by one.

So far I've got a number in the top left cell and bookmarked it 'start'. The next cell then has a SEQ field { SEQ myNums start \n} but the SEQ field simply displays 0.

Where am I going wrong?

Thanks,

Ken

User avatar
HansV
Administrator
Posts: 78930
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: simple list of sequential numbers

Post by HansV »

In the top left cell, enter a SEQ field with field code

{ SEQ myNums \r 37 }

where 37 is the starting number. In subsequent cells, add a SEQ field with field code

{ SEQ myNums }

Select the entire table and press F9 to update the fields.
S2106.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
stuck
Panoramic Lounger
Posts: 8267
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: simple list of sequential numbers

Post by stuck »

Umm, yes, I had that at one point in my thrashing around but I don't really want the user to have to open up the field code in order to set the starting value. I was hoping I could somehow pass the starting value into the SEQ field...

Can that be done?

Ken

User avatar
stuck
Panoramic Lounger
Posts: 8267
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: simple list of sequential numbers

Post by stuck »

:scratch: It's OK now. Don't now what I was doing wrong previously but the following is doing what I want:
In the first cell type in a number and bookmark that value 'start'
In the second cell inset a SEQ field { SEQ myNum \r {REF start \h} }
In third and subsequent fields use {SEQ myNum \n }

Ken

User avatar
stuck
Panoramic Lounger
Posts: 8267
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: simple list of sequential numbers

Post by stuck »

No it's not :bummer:

The second cell giving the same as the first cell.

Ken

User avatar
HansV
Administrator
Posts: 78930
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: simple list of sequential numbers

Post by HansV »

OK, go back to entering the starting number in the top left cell and bookmark it as start.
In the second cell, enter the field code

{ SEQ myNums \r {={start}+1} }

The rest of the cells can remain as { SEQ myNums }.
Best wishes,
Hans

User avatar
stuck
Panoramic Lounger
Posts: 8267
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: simple list of sequential numbers

Post by stuck »

Thank you, that is both simple and it works!

Ken

User avatar
stuck
Panoramic Lounger
Posts: 8267
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: simple list of sequential numbers

Post by stuck »

Here's a more complicated alternative that also works but does make it less likely that a user inadvertently overwrites / removes the 'start' bookmark. I worked this out after finally finding the file where I'd done this sort of thing before. I had to go back a bit though, to a mail-merge template, dated July 2000 :grin:

In the first cell:

Code: Select all

{ ASK start "enter first number" { SEQ myNum } ][}{REF start \h }
where ][ represents the location of the 'start' bookmark.

In the second cell, use Han's construct:

Code: Select all

{ SEQ myNum \r{ ={start }+1 } }
Subsequent cells:

Code: Select all

{ SEQ myNum }
User creates a file from the template, selects the entire table, presses F9 to update fields, which makes the ASK field prompt for a starting number, which in turn populates the 'start' bookmark.

:cheers:

Ken

User avatar
HansV
Administrator
Posts: 78930
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: simple list of sequential numbers

Post by HansV »

A clever solution!
Best wishes,
Hans