Yes, Rick. I ultimately want to rearrange existing rows of data into a new
ordering, but for my selection only, not the entire row. Array A only
references a single column of data, and array B is its index, if you will.
1. Can the rows of data that you are rearranging be more than two cells
wide? If so, what is the maximum number of columns?
Please note that theoretically, my selection can be the entire 65536x256 of
data, though I doubt it that any user would have that much data. So, the
number of columns vary from 1 to 256.
2. Can there be other data on the rows (either in front of or after the
data that you show being rearrange) that will not move when the designated
columns are rearranged?
Yes. I only want to re-arrange my selection.
3. What is the maximum number of rows that will ever be included for
rearrangement?
I guess, I answered this in question 2 above. The maximum number of rows is
65536.
4. Do the Index numbers appear in your a column of your spreadsheet or do
they only exist inside your code?
Both arrays A and B are only inside my code, as follows:
Dim A() as Variant, B() as Variant, N as long, i as long
N=Selection.rows.count
Redim A(N), B(N)
For i=1 to N
B(i)=i
A(i)=Cells(i, some column in my selection).value ' For example
cells(i,4) for Column D
next i
Now, once the data is calculated, it needs to be dumped into the spreadsheet
fast. I had used a loop before, but it took too long. Someone suggested
that I create a dummy 2D array containing my data and use Selection.Value =
NewDummyArray. Of course before, I did not care about the formats, but now
I am. Basically, think of what I am trying to do, like a sorting operation,
except, I am doing other stuff. I hope this helps. Thanks for your help.
Have a nice Sunday evening.
Bob