If my understanding is correct, in such a case, you don’t have to use a macro, or write it that way.
Just try these nimble steps:
(Multiple Selections should be enabled. I think you know what it is.)

Select “[1!#”;
Select All Occurrences (in context menu. Default shortcut key: CTRL+Shift+A);
(If the first string is complex, you can input a regular expression and use “Select All” button in Find dialog box;)
Press Esc key once (and only once) to collapse the selections;
(Now all the cursors should be blinking just before the numbers you are going to replace;)
Word Right Extend (Default: Ctrl+Shift+Right);
(Now all the target numbers should be selected;)
Numbering (in context menu: Advanced. Default: Alt+N);
In Numbering dialog box:
^ First Line: 1
^ Increment: 1
^ Decimal

You can record this procedure as a macro.
But I’d suggest keeping these smart commands in mind and using them deftly in different cases. I think such operations are more flexible, more interesting, and more “EmEditorism”.

However, if you’d rather use a macro of your style:

redraw = false;
var count = 1;
var strFind = "\\[1!#";
while(document.selection.Replace(strFind + "\\d+", strFind + count, eeFindReplaceRegExp | eeFindNext)) count++;