+ Reply to Thread
Results 1 to 6 of 6

swap between columns

Hybrid View

  1. #1
    Registered User
    Join Date
    08-09-2020
    Location
    jerusalm, israel
    MS-Off Ver
    2019
    Posts
    13

    swap between columns

    Hi.


    i have several columns. A-H. i want to swap between them so H will be A and G will be B ext.
    i can't sort them by small/large cause they have text in them.

    Thanks a lot

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,122

    Re: swap between columns

    Insert a row before the data. Number the columns in the order you want them. Then sort by column on row 1. Finally, delete the temporary row you inserted.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-09-2020
    Location
    jerusalm, israel
    MS-Off Ver
    2019
    Posts
    13

    Re: swap between columns

    but if i have 500 columns it will take me long.
    is there any other way by marking them all and put a formula or somthing like that?

    thanks, koby.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,736

    Re: swap between columns

    .... post a sample file: see instruction in yellow banner at top of the page.
    Last edited by JohnTopley; 12-13-2022 at 08:12 AM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,736

    Re: swap between columns

    Sub Swap_ALL()
    Dim ar, arr
    
    Sheets("sheet1").Activate
    ar = [a1].CurrentRegion
    ReDim arr(1 To UBound(ar), 1 To UBound(ar, 2))
    cc = UBound(ar, 2)
    
    For c = 1 To UBound(ar, 2)
        If cc < c Then Exit For
        For r = 1 To UBound(ar, 1)
            arr(r, c) = ar(r, cc)
            arr(r, cc) = ar(r, c)
        Next r
        cc = cc - 1
    Next c
    
    Sheets("sheet2").Activate
    [a1].Resize(UBound(arr, 1), UBound(arr, 2)) = arr
    
    End Sub
    Output on Sheet2
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-09-2020
    Location
    jerusalm, israel
    MS-Off Ver
    2019
    Posts
    13

    Re: swap between columns

    exactly.
    Thanks a lot.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] swap two columns from selection of three columns (not whole column)
    By jed38 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2013, 08:18 AM
  2. Swap columns
    By Costasg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2011, 03:27 PM
  3. How to swap rows/columns??
    By Ima in forum Excel General
    Replies: 1
    Last Post: 09-22-2009, 11:02 PM
  4. Swap Columns A and B
    By opg in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-09-2008, 04:50 PM
  5. Swap Columns A and B
    By opg in forum Excel General
    Replies: 1
    Last Post: 11-07-2008, 01:43 PM
  6. Swap Columns?
    By jcblinger in forum Excel General
    Replies: 3
    Last Post: 07-30-2008, 11:20 AM
  7. swap rows and columns
    By rudyh in forum Excel General
    Replies: 3
    Last Post: 12-14-2005, 09:30 PM
  8. [SOLVED] How to swap rows and columns?
    By no@spam.com in forum Excel General
    Replies: 5
    Last Post: 09-21-2005, 04:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1