View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Rearranging columns in a large spreadsheet

Your code runs slow because it uses Cut/Insert! Try my approach, ..it
just moves the data and so should be orders of magnitude faster.


Regarding the code below, there are 61 columns total (up the CI), so
would I extend the alphabet line out to CI? Also, is there a way to
align the sCols constant with the header label? I think otherwise
I'll need to keep track of which row goes to which column, and if
that
changes for whatever reason in the future, change this order also,
right?


I don't understand this! I thought you wanted to reorder cols and so
what does it have to do with rows? (All cols have rows! All rows have
cols!)

Assuming your headers are in row 1, the col labels are directly above.
If you want to specify fieldnames to reorder then a different approach
needs to be used...

If, as you suggest, the reorder will change often then I'm thinking a
userform that displays fieldnames (col headers) in a listbox where you
can move a selected fieldname up/down. Click a button and it's done!

OR

You could use 2 listboxes where you can add the reorder fieldnames to
the 2nd listbox, then reorder them as desired, then click a button.

Regardless, this isn't going to be a trivial project, meaning
programming experience is required beyond writing simple macros!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion