Creating Sequential Numbers for Data Merge… with a script!
Readers familiar with my articles will be aware that I have made InDesign’s Data Merge feature do some useful and sometimes unusual things, but the majority of my day-to-day work using Data Merge is sequentially numbered stationery.
The sequential numbers required for the stationery are typically prepared in a spreadsheet such as Microsoft Excel and then exported as a txt or csv file for use with the Data Merge palette. However, a free script called Indys Number Generator written by Stanislav Antos can create sequential numbers without having to open any spreadsheet software. The script has been available for some time but I feel it is a hidden gem and definitely worth discussing.
The script does have a list of its features on its website but unfortunately doesn’t feature a written how-to, and understanding some of the features can be a little confusing. So I’m taking it upon myself to explain it a bit.
The interface is split into three parts: Sequence, Member Format, and Output.
Sequence
- The first dropdown option (all integers) would fulfil the needs of most users. This creates a numerical sequence that increases by 1 and allows users to choose a start and finish number.
- The arithmetic sequence allows the increment to be larger than 1 (for example, using a step value of 5 the number sequence 5, 10, 15, 20, 25… can be created).
- The geometric sequence works differently – the number in the From field is multiplied by the Ratio field and then the next number in sequence is multiplied by the ratio field. For example, if the From number is 1, the To number is 4000 and the Ratio is 2, then the number sequence generated is 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048.
- The random sequence is misleading. The From and To numbers here indicate the possible numbers that can be generated, but the count indicates the number of final records that will be produced. For example, if the From number is 1, the To number is 10 and the count is 3, then a number sequence of 2, 6, 7 is a possible result.
- Integers selected from CSV file/texts selected from CSV file allow csv/txt databases created elsewhere to be manipulated using the Member format part of the interface.
- At any stage, the sequences generated can be shuffled or randomised by clicking the Shuffle members checkbox.
Member format
- The minimum length feature allows trailing numbers (or any character) to appear in the final result.
- Numbers can be grouped so that a sequence that may appear as 000000000 can now appear as 000-000-000 – in this instance the numbers have been separated in groups of 3 characters using a dash separator.
- Additional text before and after – a detail that could be typed in the data merge file itself, but is allowed for in this script.
- Member separator – when using this for data merge, I would always leave this as paragraph. There are options such as new line (a soft return) but when using this script as a tool for Data Merge, there is no reason to change the default “paragraph”.
Output
- The text can either be inserted into the document as a new text frame, or if a text frame is currently selected, can replace the contents of the text frame.
- Typically the second option of saving as a CSV file is the one to choose for use with Data Merge. Click the create button to choose a file name and location, make sure that a header has been assigned and click OK. This creates the CSV file that contains the sequential numbers that can then be used in a Data Merge by opening the Data Merge palette, clicking the flyout and clicking Select Data Source…
I wish the script could automatically add the data file to the Data Merge panel for us (rather than us having to do it manually after creating the CSV containing the newly created sequence).
But other than that, I love this tool. It is definitely one of my go-to scripts.
By the way, there’s another, simpler, free script (called LotteryNumbers, from Loic Aigon at Ozalto) which purely creates sequences that increase by 1 and can contain trailing zeros (if required) — this is also great for most numbering purposes.
This article was last modified on December 30, 2021
This article was first published on May 12, 2014

