Re: "Flipping" a matrix



kIc,

Thanks for your comments.

I like your approach, but as a general practice will not
write code that won't run in xl97 (assigning to arrays).

And yes, I have also discovered that one cannot assume
writing a Variant(containing an array) or Arrays directly
to a range is faster then plunking data directly in each cell.

If I was starting over with it, I believe that filling an index
row and sorting would be the way to go.

Regards,
Jim Cone
San Francisco, USA


"keepITcool" <xrrcvgpbby@xxxxxxxxx> wrote in message news:xn0ei4bgt2thdkv00ckeepitcoolnl@xxxxxxxxxxxxxxxxxxxxx
Jim,

I love your select case for the verification process, a gem!
BUT:
Using FormulaR1C1 iso FormulaLocal will screwup fewer formulas
(personally i avoid all Local string like the plague, more important
to use r1c1)
FWIW:
Textually confusing:
vbYes to Reverse Column data
to the programmer means flip the data in each column,
but to a user "Yes to Flip ROWS" is clearer.
No to flip COLUMNS" is probably clearer.
When a user breaks you should finish flipping at least the current
column. (I'd use an intermediate array(1 to rows,1 to 1) to cache the
"writedata" and avoid writing to single ranges

Following code uses 2 arrays
and can be copied into your routine...

(drawback: the writing part may be unresponsive)

Dim DataArray(), lRow&, lCol&
Application.StatusBar = "Reading"
DataArray = Rng.FormulaR1C1
ReDim CellArray(1 To Rws, 1 To Cols)
Application.StatusBar = "Flipping"
For lRow = 1 To Rws
For lCol = 1 To Cols
If Response = vbNo Then
CellArray(lRow, Cols + 1 - lCol) = DataArray(lRow, lCol)
Else
CellArray(Rws + 1 - lRow, lCol) = DataArray(lRow, lCol)
End If
Next
Next
Application.StatusBar = "Writing Flipped data"
Rng.FormulaR1C1 = CellArray
--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jim Cone wrote :
John,

You are about the first person in about 4 years (that I know about)
that has had any interest in flipping a range. Maybe you or somebody
can use this code. I like Tom's idea of just sorting the data, but
this works and it is turnkey...

.



Relevant Pages

  • Re: Code pages
    ... > used GetEncoderto write the byte arrays to the file. ... > But I also have to write to a sequential file. ... > I ended up first encoding the strings to byte arrays, writing them to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: IO with Java Objects: slow!
    ... > Writing it out to the disk in an ObjectOutputStream as a single Object ... you'll definitely find a tradeoff between Arrays (which are Objects ... and the Collections classes. ...
    (comp.lang.java.programmer)
  • Re: ADA Popularity Discussion Request
    ... is an excellent language for writing such a library, ... functions can instantiate new types automatically, ... template ... "Note that errors such as when bounds of arrays do not match raise ...
    (comp.lang.ada)
  • Re: "Flipping" a matrix
    ... I was half anticipating you were going to say something about large ... possibly break down into a subset of arrays. ... I have briefly tried your Permutations and List Files programs. ... And writing the list directly goes very fast. ...
    (microsoft.public.excel.programming)
  • tictactoe
    ... recognizing a winning strategy in a database of strategies. ... Also supply a flipHorizontal method that would flip the original ... implemented as "arrays of arrays", this method can be much simpler than ...
    (comp.lang.java.help)