+ Reply to Thread
Results 1 to 6 of 6

Copy and sort numbers in ascending order from multiple columns

  1. #1
    Registered User
    Join Date
    07-16-2008
    Location
    Calgary, AB
    Posts
    18

    Copy and sort numbers in ascending order from multiple columns

    A little help please. I've tried various ways to try to make this work to get the result that I want, but I'm not making any progress;

    Excel.png

    This is what I'm trying to accomplish. Someone inputs their job code and hours worked on that particular job for each day (on the left table). And on the right table, I'd like it to self populate with the job numbers in ascending order, without duplicating any of the job numbers. Apparently this is beyond my Excel skills and I could use a bit of help.

    Thanks in advance to any/all that help out.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy and sort numbers in ascending order from multiple columns

    For the worksheet
    Please Login or Register  to view this content.
    Button on the form
    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-16-2008
    Location
    Calgary, AB
    Posts
    18

    Re: Copy and sort numbers in ascending order from multiple columns

    Leo,

    Thanks so much for this. I knew it was way beyond my Excel skills, as I have no idea how to implement this into my worksheet. Could you point me in the right direction?

    Where do I add the first section of code?
    Where do I add the second section of code?
    How do I execute the button?

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy and sort numbers in ascending order from multiple columns

    Alt F11 to go to VBA editor
    first code for the worksheet, right click on this sheet and choose view code
    then select in boxes like you see on first image


    second code is after button submit on the userform, see image 2

    Kind regards
    Leo
    Attached Images Attached Images

  5. #5
    Registered User
    Join Date
    07-16-2008
    Location
    Calgary, AB
    Posts
    18

    Re: Copy and sort numbers in ascending order from multiple columns

    Leo,

    The Total Hours are already added up based on the job # (Code for cell O4);

    Please Login or Register  to view this content.
    Code for cell O5;

    Please Login or Register  to view this content.
    etc......

    And I've tried to get an array to sort the job codes as well, but couldn't figure it out. Using your approach, I'm going to loose the sorting & calculation of the total hours.

    I'm hesitant to add in a dialog box using VBA, as we use this primarily through Google Docs for people to fill in their time and job codes remotely. I don't know if it will behave properly if we go that route. Is there a way to get this to work using a multiple select array?

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,532

    Re: Copy and sort numbers in ascending order from multiple columns

    Here is a formula based option.
    This proposed solution employs two helper columns which may be moved and/or hidden for aesthetic purposes.
    The first helper column (Q3:Q17) is populated using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The second helper column (R3:R17) is populated using: =IF(COUNTIFS(Q$1:Q3,Q3)=1,Q3,"")
    The Job# column is populated using: =IFERROR(AGGREGATE(15,6,R$3:R$17,ROW(1:1)),"")
    The total hours per job number is calculated using: =IF(N4="","",SUMPRODUCT((D$4:J$17=N4)*(E$4:K$17)))
    If this doesn't work with the spreadsheet from which the screen shot in post #1 was taken then I would suggest uploading that spreadsheet so that we can attempt to give you a solution.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. Sort numbers in ascending order and the concatenate
    By sandubandu in forum Excel General
    Replies: 10
    Last Post: 01-16-2016, 03:11 AM
  2. Replies: 1
    Last Post: 01-16-2016, 02:07 AM
  3. Replies: 2
    Last Post: 01-16-2016, 01:41 AM
  4. Replies: 13
    Last Post: 12-19-2013, 11:06 PM
  5. how to arrange multiple columns in ascending order
    By sanjay2210.msl in forum Excel General
    Replies: 2
    Last Post: 10-29-2013, 08:26 AM
  6. How to select two columns of values and sort them into ascending order,but w/o moving them
    By jonathancook in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-10-2013, 05:51 PM
  7. Sort the numbers in ascending order by lines
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-15-2012, 04:54 PM

Tags for this Thread

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