Sorting Data (Numbers) Within a Single Cell

  • I'm using a spreadsheet to input a series of one and two digits into a particular cell. I want to be able to run a macro (via VBA code) that will sort my input into chronological / ascending order. For example, I input the numbers: 21, 10, 37, 2, 5, 44 into cell A1; the numbers will be separted by a space not a comma (,). After running the macro, cell B2 (or whatever cell) should show: 2 5 10 21 37 44. Please help!

    Also, in the same spreadsheet I want to be able to count the number of times I press the "F9" key. In the spreadsheet I have a series of calculations that excel is preforming, and by pressing "F9" the calculations are updated automatically. Please help!

    Regards.

  • Re: Sorting Data (Numbers) Within a Single Cell


    Hi,


    There may be better ways..



    use


    =SORTNUM(A1)

  • Re: Sorting Data (Numbers) Within a Single Cell


    This UDF should help. Note that the optional Delimiter argument defaults to space.


    Also for the F9 thing. Try this UDF


    Code
    1. Function calculationCount(Optional Reset As Double) As Double
    2. Static calcCount As Long
    3. Application.Volatile
    4. calcCount = calcCount + 1
    5. If Reset < 0 Then calcCount = 1
    6. calculationCount = calcCount
    7. End Function
  • Re: Sorting Data (Numbers) Within a Single Cell


    Hi,


    Try this version. It has an option to provide the delimiter as well.



    use like


    =SORTNUM(A1," ")


    or


    =SORTNUM(A1,",")


    HTH

  • Re: Sorting Data (Numbers) Within a Single Cell


    Another one:
    http://www.mrexcel.com/forum/showthread.php?t=367994

  • Re: Sorting Data (Numbers) Within a Single Cell


    Each of the UDFs work to perfection! Thank you to you all!


    Lastly, any advice you can provide as to how I can become as proficient as you in VBA programming. Please advise.