View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
TommySzalapski[_18_] TommySzalapski[_18_] is offline
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