paste in Excel

B

Bob

This sounds strange and is definitely different, but I have a need to
copy cells in one column and paste them in another column, BUT
reversed. For example, copy rows 1 thru 10 in column A and paste the
data in column D rows 1 to 10, but A1 goes in D10 and D1 is what is in
A10.

Is there some special keyboard sequence modification to the paste
command to do this kind of operation?
 
S

Salmon Egg

This sounds strange and is definitely different, but I have a need to
copy cells in one column and paste them in another column, BUT
reversed. For example, copy rows 1 thru 10 in column A and paste the
data in column D rows 1 to 10, but A1 goes in D10 and D1 is what is in
A10.

Is there some special keyboard sequence modification to the paste
command to do this kind of operation?
This is not strange. It is exactly what is needed for convolution.

There are several ways I could approach such a problem. If it is something
that has to be done often, it would be worth while developing a macro or
function. The function could use the length of the column and the location
of the cell (rwn number).

If it only has to be done once or twice, I would make two columns next to
other. One contains the data. The adjoining column is merely the ordinal
number (index) of the adjoining datum. Then sort on the index in descendin
order.

Bill
-- Fermez le Bush
 
J

JE McGimpsey

Bob said:
This sounds strange and is definitely different, but I have a need to
copy cells in one column and paste them in another column, BUT
reversed. For example, copy rows 1 thru 10 in column A and paste the
data in column D rows 1 to 10, but A1 goes in D10 and D1 is what is in
A10.

Is there some special keyboard sequence modification to the paste
command to do this kind of operation?

No, but you can use this macro to flip rows in any number of columns
(e.g., copy A1:A10 to D1:D10, then run the macro):

Public Sub FlipRange()
Dim vRange1 As Variant
Dim vRange2 As Variant
Dim nCols As Long
Dim nRows As Long
Dim i As Long
Dim j As Long
If TypeOf Selection Is Range Then
With Selection
vRange1 = .Value
nCols = UBound(vRange1, 2)
nRows = UBound(vRange1, 1)
ReDim vRange2(1 To nRows, 1 To nCols)
For i = 1 To nCols
For j = 1 To nRows
vRange2(nRows - j + 1, i) = vRange1(j, i)
Next j
Next i
.Value = vRange2
End With
End If
End Sub
 
B

Bob

Thanks.
I got it to work just fine.

Is there a way to save the macro in general rather than just in the
particular wookbook?
 
B

Bob

Well I spoke a bit too soon. The columns contain cells references, so
when the macros is used it replaces the cell reference with the actual
value. I suspect .Value is the key here. Is there something like
..Reference
or something that will do what I need?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top