Create the sequence 00000 through 99999 and bring it into random order. This you can do using an adjacent column filled with =RAND()
and sorting both the columns along the second one. Needs about 1 s to run.
Why do you think to need a “macro”? The task is very simple in interactive mode. Doing it based on a specific program is rather complicated and inefficent (concerning time and intermediary storage). Doing it basically in the same way as you might do it interactively would require to use a sorting algorithm. You may look for an appropriate implementation of quicksort. Simple enough to write it down yourself “on the fly” may only be bubblesort which is of O(n^2). Using a bubblesort from my toolbox I started the experiment with reduced size of 1000. It needed about 17 s on my 6 year old PC. 100 times the size would (roughly, theoretically) need 10000 times the time: 2 days.
There is a not so well known O(n) algorithm, too, but it isn’t easily implementable in BASIC since it needs bit-/bytewise access to the internal represenattion of numbers.
A way to create your numbers in random order from the beginning might use “Floyd’s Algorithm”. See technique C from this tutorial. I wouldn’t expect that to be efficient either and didn’t try it yet.
Using the LibO API to some depth you can also simulate the interactive way programmatically. However, sorting based on a sort descriptor can only work on cell ranges, not on declared array-variables directly filled with your numbers.
My advice: Do it interactively.