+ Reply to Thread
Results 1 to 6 of 6

how to invert a list of data with macro?

  1. #1
    Registered User
    Join Date
    03-25-2008
    Posts
    24

    how to invert a list of data with macro?

    How to invert a list of data with macro?

    Lets say.. my data:

    1
    2
    3
    4
    5

    i have a macro which will add a new row of data which becomes:

    0
    1
    2
    3
    4
    5

    after which, i wish to invert the data to:

    5
    4
    3
    2
    1
    0

    which includes the new added data. As such, formula might not work in this case..

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to invert a list of data with macro?

    Hi,

    Assuming the data is not already in numerical order and unlike your example, one way would be to use a helper column alongside your data. Enter 1 in the first row, 2 in the second row, highlight the 1 & 2 and drag the right hand bottom corner of the cell border down as necessary to autofill the helper column with 1,2,3,4 ...etc.

    Now sort your data and helper column using the descending option on your helper column.

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor jj72uk's Avatar
    Join Date
    03-22-2008
    Location
    Essex, England
    MS-Off Ver
    Work - Office 2000, Home - Office 2007E
    Posts
    360

    Re: how to invert a list of data with macro?

    Maybe this?

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-25-2008
    Posts
    24

    Re: how to invert a list of data with macro?

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    Assuming the data is not already in numerical order and unlike your example, one way would be to use a helper column alongside your data. Enter 1 in the first row, 2 in the second row, highlight the 1 & 2 and drag the right hand bottom corner of the cell border down as necessary to autofill the helper column with 1,2,3,4 ...etc.

    Now sort your data and helper column using the descending option on your helper column.

    HTH
    oh sorry i did not give a good example.
    lets say.

    10
    6
    200
    5

    then i add a new row of data:
    99
    10
    6
    200
    5

    and i want it to become

    5
    200
    6
    10
    99

    and it goes on after ending a new row of data.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to invert a list of data with macro?

    OK, just modify the technique. Put a very large number, say 999999 in the helper column against the new row, and then fill the other numbers as before with 1,2,3 etc and sort descending.

    HTH

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to invert a list of data with macro?

    Sorry, that was a typo.

    Put a very SMALL number e.g. 0.1 against the new row.

    rgds

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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