How to sort dynamic data in Microsoft Excel?

Let's say you are managing the storage data of a stationary shop in Excel, and you need to automatically sort the storage data when it changes. How do you sort the dynamic storages data automatically in Excel? This article will show you a tricky way to sort dynamic data in Excel, and keep the sorting update automatically when the original data changes at once.

Sort synamic data in Excel with formula


Sort synamic data in Excel with formula

1. Insert a new column at the beginning of the original data. Here I insert column No. before the original data as below screenshot shown:

2. Follow our example, enter formula =RANK(C2,C$2:C$6) in Cell A2 to sort original products by their storage, and press the Enter key.

3. Keep selecting cell A2, drag the Fill Handle down to cell A6 to get all rest numbers in No. column.

4: Copy the titles of the original data, and then paste them besides original table, such as E1:G1. In the Desired No. column, insert the sequence numbers same as the No. orders such as 1, 2, …. See screenshot:

5. Enter formula =VLOOKUP(E2,A$2:C$6,2,FALSE) into Cell F2, and press the Enter key.

This formula will look for the value of Desired NO. in the original table, and display the corresponding product name in the cell.

Note: If repeats or ties display in the Product column or Storage column, you’d better apply this function =IFERROR(VLOOKUP(E2,A$2:C$6,2,FALSE), VLOOKUP(E2,A$2:C$6,2,TRUE))

6. Keep selecting cell F2, drag the Fill Handle down to cell F6 to get all product names, And keep selecting range F2:F6, drag the Fill Handle right to range G2:G6 to get all storage numbers.

Then you will get a new storage table sorting in descend order by the storage as below screenshot shown:

Supposing your stationary shop purchases another 145 pens, and now you have 200 pens in total. Just modify the original table of pen's storage, you will see the new table is updated in a blink of eyes, see the following screen shot:


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    jirehl · 2 years ago
    hi,, what if there will be more than to numbers that were ties?
  • To post as a guest, your comment is unpublished.
    Wilfred · 3 years ago
    Wonderful....Thanks this helped me
  • To post as a guest, your comment is unpublished.
    Lori · 3 years ago
    I had lost the ability to sort several rows of information on one page of a spreadsheet with many pages. After trying to fix the situation by reworking formulas none of the information will sort now. Can I fix this without having to recreate page that is the problem. Same information needs to be transferred to another page that contains all information from all the pages; this too stops sort there. Big problem and don't know how to solve it.
  • To post as a guest, your comment is unpublished.
    sourabha · 4 years ago
    i need to convert a number into another format.lets take an example - no =12394567 i need to convert it into 674501239. its simple (last 2 digit in first ,then 2nd last 2 digits then add a zero(0) then first four digits in the last. can you please guys tell me the formula for this?
    • To post as a guest, your comment is unpublished.
      imjustkate · 2 years ago
      =CONCATENATE(RIGHT(A1,2),MID(A1,5,2),"0",LEFT(A1,4)) will get you that order of digits.
    • To post as a guest, your comment is unpublished.
      OptimusPrime · 4 years ago
      you can use the CONCATENATE and then LEFT or RIGHT in excel formula.
      Its easy, Got it ?
  • To post as a guest, your comment is unpublished.
    Jays · 5 years ago
    Sure, mail me the detail and I will show you the finished product
  • To post as a guest, your comment is unpublished.
    Jays · 5 years ago
    Hi, no problem, email me and I will show hulu how the finished product works.
  • To post as a guest, your comment is unpublished.
    Eli · 5 years ago
    Hi Dear,
    I have a sheet with 100 items , each item has a specific cost that happens in one year .I want to create another sheet that shows only the item that has cost in one year automatically ? for example all of the item with item No. and description and cost in 2016 and then for 2017 and so on...

    thanks
  • To post as a guest, your comment is unpublished.
    indrajit · 5 years ago
    how can i sort lowest to highest value (a to z) in your example i.e lowest storage to highest storage. i use your formulla '=RANK(C2,C$2:C $6) + COUNTIF(C$2:C2, "="&C2)-1'" & "=IFERROR(VLOOKUP(E2,A$2:C$6,2,FALSE), VLOOKUP(E2,A$2:C$6,2,TRUE))" . al is going well but i cannot sort lowest to highest.
  • To post as a guest, your comment is unpublished.
    Daniel Alfano · 5 years ago
    Kedirech, you rock!! The COUNT thing eliminates ties!! I've had this problem for years but now this is the solution!! Thanks!!
  • To post as a guest, your comment is unpublished.
    jays · 5 years ago
    Hi, I do it with if statements alone, how do I let you look at my file?
  • To post as a guest, your comment is unpublished.
    jays · 5 years ago
    You can do this (and much more) with the correct combination of If statements in any version of Excel. Only you imagination limits your capability.
    Jays
  • To post as a guest, your comment is unpublished.
    Amin Mehedi · 5 years ago
    step 1 to 6 works fine. but step 7 returns "#NAME?". plz check.
  • To post as a guest, your comment is unpublished.
    OptimusPrime · 5 years ago
    Sorry Guys, there was a mistake in my previous post.
    The correct one is as follows:

    Step1: Enter serial no 1 to 10 in cells A1 to A10 (S.No.).
    Step2: Enter any values in cells B1 to B10 (Item Qty.).
    Step3: Enter any object names in cells C1 to C10 (Item Name).
    Step4: Enter formula =RANK(B1,B$1:B$10)+COUNTIF(B$1:B1,"="&B1)-1 in cell D1. Drag till D10. (Item position)
    Step5: Enter formula =C1 in E1 and drag till E10. (Item Name as is)
    Step6: Enter formula =LARGE($B$1:$B$10,A1) in F1 and drag till F10. (Desired Item qty. in order)
    Step7: Enter formula =IFERROR(VLOOKUP(A1,D$1:E$10,2,FALSE), VLOOKUP(A1,D$1:E$10,2,TRUE)) in cell G1 and drag till G10. (Desired Item Name in order).

    Watch carefully, Your Desired Item qty. and item name would be in Cell F1 to G10.
  • To post as a guest, your comment is unpublished.
    xyz · 5 years ago
    Hello All,

    please use below instead of just Rank...

    =RANK(C2,C$2:C $6) + COUNTIF(C$2:C2,C2)-1


    works every time. Thanks to OptimusPrime!
  • To post as a guest, your comment is unpublished.
    OptimusPrime · 5 years ago
    Guys,
    Check this out for a better solution and Do as i write:

    Step1: Enter serial no 1 to 10 in cells A1 to A10 (S.No.).
    Step2: Enter any values in cells B1 to B10 (Item Qty.).
    Step3: Enter any object names in cells C1 to C10 (Item Name).
    Step4: Enter formula =RANK(B4,B$4:B$16)+COUNTIF(B$4:B4,"="&B4)-1 in cell D1. Drag till D10. (Item position)
    Step5: Enter formula =C4 in E1 and drag till E10. (Item Name as is)
    Step6: Enter formula =LARGE($B$4:$B$16,A4) in F1 and drag till F10. (Desired Item qty. in order)
    Step7: Enter formula =IFERROR(VLOOKUP(A4,D$4:E$16,2,FALSE), VLOOKUP(A4,D$4:E$16,2,TRUE)) in cell G1 and drag till G10. (Desired Item Name in order).

    Watch carefully, Your Desired Item qty. and item name would be in Cell F1 to G10.

    If still got problem, download the excel sheet, its protected and the password is password. change value in current cell and press Enter. Watch the last two columns.

    And if Still in problem ? let me know.
  • To post as a guest, your comment is unpublished.
    CHENET · 6 years ago
    Very helpful. It will help me solve problems at work and at church, specifically in Sunday school.
  • To post as a guest, your comment is unpublished.
    Pbca ER · 6 years ago
    I see some people having trouble with the repeated values. For example, what happens if two or more products have same storage count.
    =RANK would then Show the list 1,1,3,4,5 etc. So whenever you make a VLOOKUP search it would skip the skipped number, which is 2 in our example.
    Here is the solution. =VLOOKUP(SMALL(range;n);range;column;FALSE).
    SMALL formula goes finds the n th smallest value in the list. And it catches the repeated values also. Altough there is not actually a 2nd value in our sample, it goes finds the repeated 1st value.
    Hope this helps.
  • To post as a guest, your comment is unpublished.
    trader8110 · 6 years ago
    Another option I have found to eliminate an error message due to duplicates. Modify the rank formula a little bit. For the example above:

    Original Formula for A2:
    =RANK(C2,C$2:C$6)
    Revised Formula for A2:
    =RANK(C2,C$2:C$6)+(IF(C2=C1,1,0))

    Then copy that formula down for all the cells in the A column.
  • To post as a guest, your comment is unpublished.
    kevinbmfs · 6 years ago
    I need help.. I have been using vlookup in excel to look at two sheets (one sheet is from a manufacture, one sheet is from our retail sales software) which share a common vendor number in order to attach a UPC number from the manufacturer info sheet to the retail sales sheet which is then imported back in to our retail sales software. V Lookup errors all to often and I am not savy enough to know why so I was wondering if Kutools has a similar function to make my life easier.
    Again,in an attempt to clarify...Manufacture provided excel sheet contains a vendor number and a UPC number. second sheet has same vendor number and internal part number and I want a Kutool function that will compare vendor numbers and attach the UPC to the second sheet which will then be imported back into our system (using internal part number to "find" the item)
    Any help will be appreciated!! :-)
  • To post as a guest, your comment is unpublished.
    GernB · 6 years ago
    This method can eliminate duplicates without a macro for cases like the example when integers or fixed decimals are used. Add a dummy column and make incremental changes to the data to be sorted. Then follow the same process as outlined using the modified data. Using the example make column I with the formula col C + col E * 0.01. Then, change col A to rank col I instead of col C. The rest is the same. Not perfect but might help. If there are lot of items then decrease the incremental multiplier enough that the max number of items being sorted * the multiplier remains insignificant compared to the data being sorted.
  • To post as a guest, your comment is unpublished.
    Domz · 6 years ago
    Thank You so much, it works and best partnered with Graphs!
  • To post as a guest, your comment is unpublished.
    jays · 6 years ago
    Hi Help ,have you tried a pivot table?
  • To post as a guest, your comment is unpublished.
    Beast101za · 6 years ago
    Hi I am finding the Above useful in 2007 however the Company I work for still only uses office 97 will this work in that.

    Kind Regards
  • To post as a guest, your comment is unpublished.
    Hepp · 6 years ago
    Hi

    I am trying to create a dart averages table, for multiple teams,so that each match when I enter data it automatically calculates on another page on the same sheet.
    Rank Name Pl W L 100+ 140+ 180 Av D/Av
  • To post as a guest, your comment is unpublished.
    Jim101 · 6 years ago
    Thank you for this help. I have one problem. This Ranks things from largest to smallest. I need to do the opposite and rank them smallest to largest. How do I change this.
    • To post as a guest, your comment is unpublished.
      Kedirech · 6 years ago
      [quote name="Jim101"]Thank you for this help. I have one problem. This Ranks things from largest to smallest. I need to do the opposite and rank them smallest to largest. How do I change this.[/quote] The rank function has an optional 3rd argument. By default it's set to order largest to smallest. But if you use 1 for the 3rd argument, RANK(C2,C$2:C$6,1), it will sort in the opposite order.
  • To post as a guest, your comment is unpublished.
    jays · 6 years ago
    Numbers in a must be unique and those in b must also spat in a
  • To post as a guest, your comment is unpublished.
    jays · 6 years ago
    If the figures in A and B are always be going to be unique (no duplicate per column and each one in Coln B also appears in A) then it should be fairly easy.
  • To post as a guest, your comment is unpublished.
    Basit · 6 years ago
    #jays,- i would appreciate any solution with or without vbasic or excel formulas.
  • To post as a guest, your comment is unpublished.
    jays · 6 years ago
    #Basit - I would like to see a solution without vbasic or macros.
  • To post as a guest, your comment is unpublished.
    Basit · 6 years ago
    hi guys, this page is really useful. I need an excel formula or vb code what works fine for problem. my problem is that i have a list of numeric range, lets say, 1 to 100 in ascending order in column A. I have the same numeric range in random order in column B and I have different scores in column C in random order. All i want is to sort the random range of column C with the same number against it in column C according to the ascending order of range in column A.I want to sort column B but along with scores in column C as well. for example,
    Column A Column B Column C
    1
    2 10 25
    3 4 60
    4 9 95
    5 2 30
    6
    7 6 20
    8 5 31
    9 3 45
    10 1 55
    in column B, there are two digits (7 &8) missing. i just want that column B be sorted against each digit in column A, like 1 in front of 1 and 2 in front 2 and missing should remain blank in column B in front of 7 & 8 in column A.
    Column A Column B Column C
    1 1 55
    2 2 30
    3 3 45
    4 4 60
    5 5 31
    6 6 20
    7
    8
    9 9 95
    10 10 25

    I hope i have complicated it a lot but plz somebody help me out.
  • To post as a guest, your comment is unpublished.
    DIEGO MEDINA · 6 years ago
    IM USING THIS FORMULA
    =IFERROR(VLOOKUP(I3,CALCULATIONS!I$2:K$7,2,FALSE),(VLOOKUP(I3,CALCULATIONS!I$2:K$7,2,TRUE)))

    Now I have a problem... If 2 or more people have the same points, excel repeats the name. What should I add in the formula to avoid repeated names when they have the same amount of points?

    Thank you
  • To post as a guest, your comment is unpublished.
    Will · 6 years ago
    Hi, I am using this to make a dynamic league ladder, is there anyway to have multiple teams have the same ranking. For example, if 5 teams have 4 points and 5 teams have 0 points, the vlookup will only lookup the first of each.

    [b]This is the raw data:[/b]
    Pos. Team P W L Pts
    1 Team 1 1 1 0 4
    6 Team 2 1 0 1 0
    1 Team 3 1 1 0 4
    6 Team 4 1 0 1 0
    1 Team 5 1 1 0 4
    6 Team 6 1 0 1 0
    1 Team 7 1 1 0 4
    6 Team 8 1 0 1 0
    1 Team 9 1 1 0 4
    6 Team 10 1 0 1 0

    [b]This is the vlookup table of the table above:[/b]
    Pos. Team P W L Pts
    1 Team 1 1 1 0 4
    2 #N/A #N/A #N/A #N/A #N/A
    3 #N/A #N/A #N/A #N/A #N/A
    4 #N/A #N/A #N/A #N/A #N/A
    5 #N/A #N/A #N/A #N/A #N/A
    6 Team 2 1 0 1 0
    7 #N/A #N/A #N/A #N/A #N/A
    8 #N/A #N/A #N/A #N/A #N/A
    9 #N/A #N/A #N/A #N/A #N/A
    10 #N/A #N/A #N/A #N/A #N/A



    Please help! Thanks a million :D
  • To post as a guest, your comment is unpublished.
    Mandla · 6 years ago
    Great help guys. thank you.
  • To post as a guest, your comment is unpublished.
    Fanynn · 6 years ago
    what if there are more than 2 repeats in storage column? it doesn't work well with the '=IFERROR(VLOOKUP(E2,A$2:C$6,2,FALSE), VLOOKUP(E2,A$2:C$6,2,TRUE))' method
    • To post as a guest, your comment is unpublished.
      Charles · 6 years ago
      Did you ever get an answer on this? I've got the same problem when I have 3 or more values that are the same.
  • To post as a guest, your comment is unpublished.
    Gaz · 6 years ago
    hi just wanted to say thanks for this page! have been searching the web for a week and this page (plus Kedirech's comment) has solved it!! cheers!
  • To post as a guest, your comment is unpublished.
    StayLens · 6 years ago
    can you have multiple ranking columns in excel and use the sort function to be able to rank in numerical order
  • To post as a guest, your comment is unpublished.
    SteveB90 · 7 years ago
    I tried this and it worked as long as all of the ranked values are unique. If there is a tie in the ranking, the VLOOKUP will return #N/A. This creates a problem because I cannot ensure there will not be any ties in my ranking as the values change. In other words, if "Pencil" and "Notebook" are both equal to 80, then RANK returns 1,2,3,3,5. And since the values in the Desired No. field were mannually entered as 1,2,3,4,5, VLOOKUP will not find a "4".
    • To post as a guest, your comment is unpublished.
      Kedirech · 7 years ago
      Instead of just using '=RANK(C2,C$2:C$6)' in column A, you can use '=RANK(C2,C$2:C$6) + COUNTIF(C$2:C2, "="&C2)-1' This will go by the rank, but then count the number of duplicates that are already in the list. This will ensure that you get a unique ranking.
      • To post as a guest, your comment is unpublished.
        Manjunath · 3 years ago
        Excellent Tip...was looking for some solution for this problem all over the internet. Finally found here
        It's amazing how people in different parts of the globe are having the similar requirement at the same time!!
      • To post as a guest, your comment is unpublished.
        Thomas · 4 years ago
        Kedirech, thank you SOOOO much, this worked perfectly.
      • To post as a guest, your comment is unpublished.
        Daniel Alfano · 5 years ago
        Thanks Kedirech!!! This COUNTIF solved the tie issue!!
      • To post as a guest, your comment is unpublished.
        Uttam Saini · 5 years ago
        Thanks Kedirech..this solved my problem
    • To post as a guest, your comment is unpublished.
      HelloKelly · 7 years ago
      Hi SteveB90,
      Thanks for your comment. The =VLOOKUP(E2,A$2:C$6,2,FALSE) will match the data exactly, so it goes wrong if ties happen.

      In this case, you can try the approximate matching function [i][b]=IFERROR(VLOOKUP(E2,A$2:C$6,2,FALSE), VLOOKUP(E2,A$2:C$6,2,TRUE))[/b][/i], which work well if ties come out. And hope it works for you.
  • To post as a guest, your comment is unpublished.
    Johann · 7 years ago
    Hi,

    I can do the same without Kutools and in your example iso changing the amount for pencils, you can add another line, repeat pencils and add the additional amount and my spreadsheet will display pencils only once (it does not matter how many pencil entries there are)with the total amount. Plain Excel without Macros, VB Code, Access, D Base, etc. I would love to show you.