![]() |
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 |
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 |
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 |
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 *** |
All times are GMT +1. The time now is 02:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com