jomili
09-28-2012, 01:37 AM
Rick,
I'm using your SWAP Columns macro (http://www.excelfox.com/forum/f22/swapping-rearranging-multiple-columns-data-493/) , and am having an issue. See the attachment with before and after sheets. I've posted the macro below, configured the way I'm using it. The problem is that Column Z, "Contract Manager Region" in the "Before" tab, is being deleted in the "After" tab, and Column AE, "Subject" in the "Before" tab, is being correctly moved to Column E in the "After" tab, but is also staying in AE in the "After" tab, where "Contract Manager Region" should be. Do I have something configured wrong?
Sub RearrangeColumns()
'http://www.excelfox.com/forum/f22/swapping-rearranging-multiple-columns-data-493/
'in the code as expressed below, column C moves to first position, B stays in second, E is thrd, etc.
'Const NewOrder As String = "C,B,E,F,H,AC,K,AF,T,M,S,G,X,I,Z,AA,L,AG,AE,AH,AD,A I,A,D,J,N,O,P,Q,R,U,V,W,Y,AB,AJ"
Dim X As Long, LastRow As Long, Letters As Variant
'Type in order of what column you want in what position
'Make sure there are no spaces in this string
Const NewOrder As String = "D,E,AC,AD,AE,AB,B,C,F,G,H,I,J,K,L,M,N,P,X,Y,Q,R,S, T,U,V,W,A,AA,O,Z"
LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
Letters = Split(NewOrder, ",")
For X = 0 To UBound(Letters)
Letters(X) = Columns(Letters(X)).Column
Next
Range("A1").Resize(LastRow, UBound(Letters)) = Application.Index(Cells, Evaluate("ROW(1:" & LastRow & ")"), Letters)
End Sub
I'm using your SWAP Columns macro (http://www.excelfox.com/forum/f22/swapping-rearranging-multiple-columns-data-493/) , and am having an issue. See the attachment with before and after sheets. I've posted the macro below, configured the way I'm using it. The problem is that Column Z, "Contract Manager Region" in the "Before" tab, is being deleted in the "After" tab, and Column AE, "Subject" in the "Before" tab, is being correctly moved to Column E in the "After" tab, but is also staying in AE in the "After" tab, where "Contract Manager Region" should be. Do I have something configured wrong?
Sub RearrangeColumns()
'http://www.excelfox.com/forum/f22/swapping-rearranging-multiple-columns-data-493/
'in the code as expressed below, column C moves to first position, B stays in second, E is thrd, etc.
'Const NewOrder As String = "C,B,E,F,H,AC,K,AF,T,M,S,G,X,I,Z,AA,L,AG,AE,AH,AD,A I,A,D,J,N,O,P,Q,R,U,V,W,Y,AB,AJ"
Dim X As Long, LastRow As Long, Letters As Variant
'Type in order of what column you want in what position
'Make sure there are no spaces in this string
Const NewOrder As String = "D,E,AC,AD,AE,AB,B,C,F,G,H,I,J,K,L,M,N,P,X,Y,Q,R,S, T,U,V,W,A,AA,O,Z"
LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
Letters = Split(NewOrder, ",")
For X = 0 To UBound(Letters)
Letters(X) = Columns(Letters(X)).Column
Next
Range("A1").Resize(LastRow, UBound(Letters)) = Application.Index(Cells, Evaluate("ROW(1:" & LastRow & ")"), Letters)
End Sub