Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default reversing order of columns of data

Hi
This may be simple: I have a sheet that has the dates Jan 1 thru Dec 31 in
column A. Then in columns B on out I have years 1890 - 2005. I have the high
temps for each day in each of the years columns(Col B is 1890; Col C is
1891;etc.). I would like to reverse the order from 1890-2005 to 2005-1890.
(eg. Col B - 2005; Col C - 2004) What macro would work the best? Thanks,
Jim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default reversing order of columns of data

select columns B to the last column. Then do

Data=sort
Select options button and choose left to right.

Specify your row of dates as the key field (assume row 1)

--
Regards,
Tom Ogilvy

"Jim Brass" wrote in message
...
Hi
This may be simple: I have a sheet that has the dates Jan 1 thru Dec 31 in
column A. Then in columns B on out I have years 1890 - 2005. I have the

high
temps for each day in each of the years columns(Col B is 1890; Col C is
1891;etc.). I would like to reverse the order from 1890-2005 to 2005-1890.
(eg. Col B - 2005; Col C - 2004) What macro would work the best? Thanks,
Jim




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default reversing order of columns of data


Select the stuff you want flipped and run this macro

Sub flipHorizontal()

Dim iRows, iCols, iTop, iBottom, iLeft, iRight As Integer
Dim temp As Variant

If Selection Is Nothing Then

Else

iRows = Selection.Rows.Count
iCols = Selection.Columns.Count

iTop = Selection.Row
iBottom = iTop + iRows - 1
iLeft = Selection.Column
iRight = iLeft + iCols - 1

For i = 0 To CInt(iCols / 2) - 1
temp = Range(Cells(iTop, iLeft + i), Cells(iBottom, iLeft
i)).Value
Range(Cells(iTop, iLeft + i), Cells(iBottom, iLeft + i)).Value _
= Range(Cells(iTop, iRight - i), Cells(iBottom, iRight
i)).Value
Range(Cells(iTop, iRight - i), Cells(iBottom, iRight - i)).Valu
= temp
Next i

End If

End Su

--
TommySzalapsk
-----------------------------------------------------------------------
TommySzalapski's Profile: http://www.excelforum.com/member.php...fo&userid=2556
View this thread: http://www.excelforum.com/showthread.php?threadid=39063

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default reversing order of columns of data


Thanks! I never looked at the options button before. It worked slick!


*** Sent via Developersdex http://www.developersdex.com ***
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
Reversing order of text Sonics Excel Discussion (Misc queries) 2 December 17th 09 02:42 PM
Reversing data in columns CT EA New Users to Excel 2 July 15th 09 11:03 PM
Reversing the order of data separated by commas within a cell? rome330 Excel Discussion (Misc queries) 5 February 9th 09 07:21 PM
Reversing the Order of a String carl Excel Worksheet Functions 6 December 7th 04 11:26 AM
Reversing the order of a chart Art Excel Programming 4 May 30th 04 02:16 PM


All times are GMT +1. The time now is 04:49 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"