Results 1 to 10 of 14

Thread: Swapping (Rearranging) Multiple Columns of Data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    A sorting alternative:
    Code:
    Sub snb()
      sn = Split("C,F,A,G,B,J,E,D,I,H", ",")
      For j = 0 To UBound(sn)
        sn(j) = Columns(sn(j)).Column
      Next
    
      Cells(1).CurrentRegion.Rows(1).Offset(Cells(1).CurrentRegion.Rows.Count) = sn
      With Cells(1).CurrentRegion
        .Sort Cells(.Rows.Count, 1), , , , , , , , , , xlSortRows
        .Rows(.Rows.Count).ClearContents
      End With
    End Sub
    or if the number of columns doesn't exceed the alphabet:

    Code:
    Sub snb_002()
      Cells(1).CurrentRegion.Offset(10) = Application.Index(Cells(1).CurrentRegion, Evaluate("Row(" & Cells(1).CurrentRegion.Address & ")"), [transpose(code(mid("CFAGBJEDIH",row(1:10),1))-64)])
    end sub
    Last edited by snb; 08-11-2012 at 06:44 PM.

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2013, 07:34 AM
  2. Converge Data From Multiple Columns To Single Column
    By ayazgreat in forum Excel Help
    Replies: 3
    Last Post: 12-14-2012, 10:55 PM
  3. Swapping columns Error 2
    By jomili in forum Excel Help
    Replies: 1
    Last Post: 11-16-2012, 08:52 PM
  4. Swapping Multiple Columns of Data
    By jomili in forum Excel Help
    Replies: 5
    Last Post: 10-01-2012, 05:56 PM
  5. Replies: 2
    Last Post: 06-14-2012, 04:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •