phreshsprout
phreshsprout

Reputation: 59

How to create a reverse sort on an Excel array

I have an array of 250 elements "myArray (1 to 250)". Is there a built-in excel for mac function that can give me a reverse number list? For example if I wanted to loop through the array from the last number to the first (250 to 1), the last number could have a pointer as the 1st item processed in my loop ie. 250 is the 1st processed, 249 is the second processed, 248 is the third, etc? My goal is using a built-in function vs creating a logic loop.

Upvotes: 0

Views: 65

Answers (1)

Ron Rosenfeld
Ron Rosenfeld

Reputation: 60174

Is there a special requirement in VBA / MAC that precludes negative Step counters?

If not, just do something like:

For X = Ubound(myArray) to Lbound(myArray) Step -1
    Do Something
Next X

Upvotes: 1

Related Questions