+ Reply to Thread
Results 1 to 2 of 2

Flipping columns in entire selections

Hybrid View

  1. #1
    Registered User
    Join Date
    12-18-2011
    Location
    london, england
    MS-Off Ver
    Excel 2003, 2007
    Posts
    75

    Flipping columns in entire selections

    I am trying to flip the desired selection around. making the bottom of the column, all the way up to the top, along with all the items in the same row.

    How do I go about it in vba, while also adding it default button in my paste special menu?
    Thanks.

  2. #2
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: Flipping columns in entire selections

    One way of doing it (not in the most elegant way) is this. Using an additional sheet, copy the range starting from the bottom and then copy the result over the original selection. After that, delete the helping additional sheet.

    Sub reverse()
        Dim csh As Worksheet
        Dim addsh As Worksheet
        Dim lr As Long, add As String
        Dim i As Long, sel As String
        
        Application.ScreenUpdating = False
        sel = Selection.Address
        add = Selection(1, 1).Address
        lr = Selection.Rows.Count
        Set csh = ActiveSheet
        Set addsh = Sheets.add(, csh)
       
        For i = lr To 1 Step -1
            Range(sel).Rows(i).Copy addsh.Range("A" & lr - i + 1)
        Next
        
        addsh.UsedRange.Copy csh.Range(add)
        addsh.Delete
        Application.ScreenUpdating = True
    End Sub
    Last edited by bulina2k; 01-25-2016 at 04:33 AM. Reason: optimized for speed
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

+ 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. Matching 2 drop down selections in 2 different columns to retrieve a value
    By davidnovak1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-15-2015, 09:27 PM
  2. [SOLVED] Moving multiple selections to other columns on same sheet
    By Lucille Boshoff in forum Excel General
    Replies: 5
    Last Post: 02-03-2015, 06:01 AM
  3. Combine dropbox selections into new columns?
    By oceanorigami in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2014, 09:17 AM
  4. Align Primary and Secondary Axis Dates W/O Flipping Columns?
    By clw496 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-02-2013, 06:46 PM
  5. Flipping columns with multiple row selection
    By klonbeck in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 05:46 PM
  6. Replies: 0
    Last Post: 02-14-2012, 05:13 PM
  7. PIVOT TABLE : Flipping Row/Columns
    By dvent in forum Excel General
    Replies: 2
    Last Post: 03-11-2010, 11:24 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