Results 1 to 3 of 3

Thread: Need help in excel

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Need help in excel

    Hi I want to ask how I can change the Columns left to right, right to left
    and also row Up to down, down to up. for example I have text in Excel
    sheet like this:

    EXAMPLE – 1 Column Left - Right
    [ ][ A ][ B ][ C ][ D ][ E ][ F ]
    [ 1 ] Aa Ba Ca Da Ea Fa
    [ 2 ] Ab Bb Cb Db Eb Fb
    [ 3 ] Ac Bc Cc Dc Ec Fc

    And I want to change lift to right like this.

    [ ][ A ][ B ][ C ][ D ][ E ][ F ]
    [ 1 ] Fa Ea Da Ca Ba Aa
    [ 2 ] Fb Eb Db Cb Bb Ab
    [ 3 ] Fc Ec Dc Cc Bc Ac

    EXAMPLE – 2 Row Up - Down
    [ ][ A ][ B ][ C ][ D ][ E ][ F ]
    [ 1 ] Aa Ab Ac
    [ 2 ] Ba Bb Bc
    [ 3 ] Ca Cb Cc
    [ 4 ] Da Db Dc
    [ 5 ] Ea Eb Ec
    [ 6 ] Fa Fb Fc

    And I want to change up to down like this.

    [ ][ A ][ B ][ C ][ D ][ E ][ F ]
    [ 1 ] Fa Fb Fc
    [ 2 ] Ea Eb Ec
    [ 3 ] Da Db Dc
    [ 4 ] Ca Cb Cc
    [ 5 ] Ba Bb Bc
    [ 6 ] Aa Ab Ac

    I hope my question is understandable, please tell me that it is possible
    or no?

    Thank you for your attention.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need help in excel

    You can do each one by invoking the .Sort method f the range.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Need help in excel

    csKanna:

    I don't know if RobDog helped you or not, but here is a simple code loop to reverse any number of columns starting with Column A:
    Code:
    Option Explicit
    Sub ReverseColumns()
        Dim numCols As Integer ' Number of Columns to roll
        Dim i As Integer
        
        'Set the number of Columns to Roll
        numCols = 6
        
        'Iterate through the Columns rolling column A into the correct location
        For i = (numCols + 1) To 3 Step -1
            Columns(1).Cut
            Cells(1, i).Insert Shift:=xlToRight
        Next i
    
    End Sub
    Can you figure out the loop for Rows? We'll help you with that as well if you need it, but we will need to know how you plan to determine the number of rows to invert.

    Of course you can easily pass the 'Number of Columns' as a parameter to this function.
    Last edited by Webtest; May 22nd, 2006 at 02:15 PM.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

Posting Permissions

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



Click Here to Expand Forum to Full Width