Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Changing Column Order (Not Rows) with Sort Function

Hello all,

I thought this would be easy - but I'm obviously mistaken. I want to
be able to order my columns in ascending or descending order (left to
right).

For examply A1 = Apple, B1 = Peach, C1 = Banana. I want to move
Banana (and all of its rows) between the Apple column and Peach
column. Could someone give me a chunk of sample code using sort
please. I've tried most everything but keep getting object errors as
soon as I throw in XLSortOrientation.

Any insight would be greatly appreciated!

Thanks!

Trip
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Changing Column Order (Not Rows) with Sort Function

Hi Trip.

Try:

Sub SortLrftToRight()
Dim rng As Range

Set rng = Range("A1:G10") '<==========AMEND!!

rng.Sort _
Key1:=rng(1), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlLeftToRight

End Sub

---
Regards,
Norman

"Trip Ives" wrote in message
om...
Hello all,

I thought this would be easy - but I'm obviously mistaken. I want to
be able to order my columns in ascending or descending order (left to
right).

For examply A1 = Apple, B1 = Peach, C1 = Banana. I want to move
Banana (and all of its rows) between the Apple column and Peach
column. Could someone give me a chunk of sample code using sort
please. I've tried most everything but keep getting object errors as
soon as I throw in XLSortOrientation.

Any insight would be greatly appreciated!

Thanks!

Trip



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Changing Column Order (Not Rows) with Sort Function

Just to add:
Easiest way to get the code and argument values is to turn on the macro
recorder while you do it manually.

--
Regards,
Tom Ogilvy

"Trip Ives" wrote in message
om...
Hello all,

I thought this would be easy - but I'm obviously mistaken. I want to
be able to order my columns in ascending or descending order (left to
right).

For examply A1 = Apple, B1 = Peach, C1 = Banana. I want to move
Banana (and all of its rows) between the Apple column and Peach
column. Could someone give me a chunk of sample code using sort
please. I've tried most everything but keep getting object errors as
soon as I throw in XLSortOrientation.

Any insight would be greatly appreciated!

Thanks!

Trip



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
numbering rows in order 1 through whatever, then changing. PO1Draco Excel Discussion (Misc queries) 1 June 21st 08 06:14 PM
How do I sort or filter rows without column A data changing? Kesbutler Excel Discussion (Misc queries) 7 July 27th 07 10:57 PM
sorting rows without changing order of my values! roger Excel Discussion (Misc queries) 1 March 3rd 06 12:24 PM
sort rows in alphabetical order and move the corresponding data lianeanddave Excel Worksheet Functions 3 August 26th 05 04:43 PM
Sort Rows in order and re-align cross table Mickey[_3_] Excel Programming 0 October 14th 03 10:45 PM


All times are GMT +1. The time now is 06:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"