Is it possible to use the Insert Number feature in column mode?
That would not be so hard to use. It could be done without macro.
If this is not possible here is a macro which could to the job. The UltraEdit macro language does not support variables and mathematical operations. Although I have written and posted macros which increases a number from 1 til 99 with a sequence of IfCharIs commands, I think that in this situation a different and easier method should be used.
The macro first creates a new file and creates in a loop the specified number of empty lines. Modify the red highlighted loop number to specify the amount of numbers you need for your special replace in the source file. Run a find with your search string with Count All before macro execution and you will know how many numbers you will need.
Next it uses the Insert Number feature in column mode to create the numbers. You could modify the green highlighted start number. It's also possible to create the numbers in hex or with leading zeros or with a different step. See options of ColumnInsertNum command.
The following replace is used to collect all numbers in a single line. This is not really needed, if instead of Key DEL the command DeleteLine is used in the macro. But I think it is faster with this method. If you have enabled by default wrapping or only a low maximum number of characters per line then better use the method without the Replace but with DeleteLine.
All preparations are done. The macro now starts the replace loop. In the loop it selects the current number and cuts it to user clipboard 9 and deletes the space (or line if DeleteLine is used here).
Back to main source window and run the replace once. Modify this replace according to your needs. If the string is not found anymore, the temporary file with the numbers is deleted before the loop exits.
If the amount of numbers was not enough, you will get an error message in the temporary file before the loop exits. The cursor in the main source file is then at end of the last replace. Look at the last number, modify the green start number in the macro, delete the temporary file with the error message and run the macro again to continue the replace job from current cursor position in the source file.
Note: The macro always executes the replaces from current position in the main source file at start of the macro!
Finally it clears user clipboard 9 and switches back to the windows clipboard.
Note: This macro needs the macro property Continue if a Find with Replace not found enabled!
ColumnInsertNum 1 1
Replace All " "
Replace "^c abc"
"Sorry, amount of numbers was not enough!"