+ Reply to Thread
Results 1 to 8 of 8

Arrange numbers in the row according to cells with value only

  1. #1
    Registered User
    Join Date
    12-14-2013
    Location
    Ukraine
    MS-Off Ver
    Excel 2013
    Posts
    25

    Arrange numbers in the row according to cells with value only

    Hi, there!!
    I have the macro which takes the values from the table and write them into given cells in the row:

    Please Login or Register  to view this content.
    Row looks like this:

    1.JPG

    My goal now is rearrange the numbers in the same row from min to max. I've tried to use excel build in "Sort" function but it's destroy the row after values sorting:

    2.JPG

    I need to keep the order (value-arrow, value-arrow...)
    it is possible to make it work somehow using vba (add the code into existing macro)?
    Thank you in advance,
    Igor
    Last edited by igor7; 05-06-2014 at 09:28 AM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Arrange numbers in the row according to cells with value only

    You should describe the actual setup of your sheet, or post a workbook, rather than a trimmed picture that shows nothing useful. Anyway, the better way is to not sort, but assign the values to the cells, like so, which will arrange the values from lowest to highest, in columns B, D, F, .... Z of row 45.

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 05-06-2014 at 10:02 AM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    12-14-2013
    Location
    Ukraine
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Arrange numbers in the row according to cells with value only

    Thank you for the answer and sorry for inconvenience...
    I've used your code in the file but it's didn't work... it return following error:
    Attachment 316377
    I've attached whole excel file. I need arrange colored values from min to max in row 45 (after "k=1") and keep existing format (value-arrow):
    Gupta File
    Appreciate your help!!

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Arrange numbers in the row according to cells with value only

    You need to run your macro first, to put values in, and change the range from B:Z to B:T, and the upper on the loop. The macros can be combined like so - Note that the Chr(...) to return the column letter breaks down after Z, so better to use a number, and it is always a bad idea to increment your loop control variable within the loop.

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 05-06-2014 at 12:29 PM.

  5. #5
    Registered User
    Join Date
    12-14-2013
    Location
    Ukraine
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Arrange numbers in the row according to cells with value only

    WOW!!
    Thanks for quick replay!! Now it's working!!
    I'm just learning to use vba so you help is much appreciated!
    May be you can help me with additional question...
    Within the same file under A45 (k = 1) row I have "Job" row.
    So in this row I should arrange job numbers (1,2,3,4,5,6,7,8,9,10) according to the colored values it the table.
    For example if value "-0.17" belong to job "1" in the "Job" row I should write "1" under "-0.17" value.
    In other words after values are arranged from min to max in the row "job" should be job numbers arranged accordingly.
    Than you in advance,
    igor
    Last edited by igor7; 05-06-2014 at 12:52 PM.

  6. #6
    Registered User
    Join Date
    12-14-2013
    Location
    Ukraine
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Arrange numbers in the row according to cells with value only

    So far I've find the way to do what I need with simple cell command (repeated in each cell accordingly):

    Please Login or Register  to view this content.
    But problem with this method that if there same number appeared in different cells (for example C15 and C18) it always pick up first in the order.

    I've also tried to add to the code above line:
    Please Login or Register  to view this content.
    Like this:

    Please Login or Register  to view this content.
    But it's writing numbers in the order (1, 2, 3 and so on) without relation that I need.
    Your help will be much appreciated!

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Arrange numbers in the row according to cells with value only

    When you need to sort values keeping things together, it is better to create a range to sort elsewhere. Try it this way, which assumes that rows 145 and 146 are blank.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-14-2013
    Location
    Ukraine
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Arrange numbers in the row according to cells with value only

    Thanks!
    I'm even didn't think it this way!!

+ 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. Replies: 2
    Last Post: 03-29-2014, 10:04 AM
  2. macro to arrange rows in numerical order using numbers in column
    By blairw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-19-2013, 10:58 PM
  3. [SOLVED] Arrange numbers in a sequence
    By Joe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-13-2006, 12:50 AM
  4. [SOLVED] How do I arrange numbers in asending order in Excel?
    By Linds in forum Excel General
    Replies: 2
    Last Post: 08-15-2005, 11: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