ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reverse Order of Copy (https://www.excelbanter.com/excel-programming/386582-reverse-order-copy.html)

Kirk P.

Reverse Order of Copy
 
I've got this code which works as expected:

Dim myRange As Range
Set myRange = Selection
Range(myRange.Address).Select
Selection.Copy
Range("Q8").Select
ActiveSheet.Paste

What I would like is for the copy beginning at Q8 to be in the reverse order
from what's in myRange. How would I accomplish this?

Jim Rech

Reverse Order of Copy
 
in the reverse order

It's impossible to say since you haven't defined 'reverse order'. For
instance if the selection is A1:A4,C3:D3,D3:D5,C11:D11,D14:D16,C20 what
would the reverse order be?

Btw your posted code is a bit more complex that needed. This is all you
need:

Selection.Copy Range("Q8")

--
Jim
"Kirk P." wrote in message
...
I've got this code which works as expected:

Dim myRange As Range
Set myRange = Selection
Range(myRange.Address).Select
Selection.Copy
Range("Q8").Select
ActiveSheet.Paste

What I would like is for the copy beginning at Q8 to be in the reverse
order
from what's in myRange. How would I accomplish this?



Kirk P.

Reverse Order of Copy
 
myRange is always a selection in a single row, such as A1:A4. The reverse
order would be A4:A1.

"Jim Rech" wrote:

in the reverse order


It's impossible to say since you haven't defined 'reverse order'. For
instance if the selection is A1:A4,C3:D3,D3:D5,C11:D11,D14:D16,C20 what
would the reverse order be?

Btw your posted code is a bit more complex that needed. This is all you
need:

Selection.Copy Range("Q8")

--
Jim
"Kirk P." wrote in message
...
I've got this code which works as expected:

Dim myRange As Range
Set myRange = Selection
Range(myRange.Address).Select
Selection.Copy
Range("Q8").Select
ActiveSheet.Paste

What I would like is for the copy beginning at Q8 to be in the reverse
order
from what's in myRange. How would I accomplish this?




Bernard Liengme

Reverse Order of Copy
 
This seems to do what you want
Sub ReverseCopy()
Set myRange = Selection
Mycount = myRange.Count
k = 17
For j = 1 To Mycount
Cells(8, k + Mycount) = myRange(j)
k = k - 1
Next j
End Sub

best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Kirk P." wrote in message
...
I've got this code which works as expected:

Dim myRange As Range
Set myRange = Selection
Range(myRange.Address).Select
Selection.Copy
Range("Q8").Select
ActiveSheet.Paste

What I would like is for the copy beginning at Q8 to be in the reverse
order
from what's in myRange. How would I accomplish this?




Jim Rech

Reverse Order of Copy
 
myRange is always a selection in a single row, such as A1:A4.

Assuming you meant a single column since that what A1:A4 is:

Sub a()
Dim CellCount As Long
Dim Counter As Long
CellCount = Selection.Rows.Count
For Counter = 1 To CellCount
Selection.Cells(Counter).Copy Range("Q8").Offset(CellCount -
Counter)
Next
End Sub

I'd doing a copy/paste because that's what you asked for. That's what you
need if you want cell formats and/or formulas transferred as opposed to just
values, which is the road Bernard was taking.

--
Jim
"Kirk P." wrote in message
...
myRange is always a selection in a single row, such as A1:A4. The reverse
order would be A4:A1.

"Jim Rech" wrote:

in the reverse order


It's impossible to say since you haven't defined 'reverse order'. For
instance if the selection is A1:A4,C3:D3,D3:D5,C11:D11,D14:D16,C20 what
would the reverse order be?

Btw your posted code is a bit more complex that needed. This is all you
need:

Selection.Copy Range("Q8")

--
Jim
"Kirk P." wrote in message
...
I've got this code which works as expected:

Dim myRange As Range
Set myRange = Selection
Range(myRange.Address).Select
Selection.Copy
Range("Q8").Select
ActiveSheet.Paste

What I would like is for the copy beginning at Q8 to be in the reverse
order
from what's in myRange. How would I accomplish this?






All times are GMT +1. The time now is 05:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com