1

I have an Excel spreadsheet that I use as a working index for my school's yearbook and the page numbers each person is on gets listed in a column on the same row as their name. Is there a way I could add a page number to the cell and have it sort automatically lowest to highest and separate each value with a comma followed by a space then the next value? I'm wanting it to do this so all I have to do is find the line the person is in the spreadsheet and add the new page number to the end of the existing page numbers without figuring where it needs to appear. ex: if I have the values 3,2,45,22 in a cell can I get it to auto organize it to 2, 3, 22, 45?

I'm looking to do this not to be lazy, but rather efficiency to eliminate a step that takes a little extra time but could really help me out.

tech_geek23
  • 229
  • 2
  • 10
  • 23

1 Answers1

1

If you can do Excel VBA, then yes. you could setup a VBA function that uses split to divide the cell contents by a "comma followed by a space" ,. Add those to an array and sort it (see here for a vba sort code sample)

Edit: Even better, here is a similar question answered: excel: how do i sort within a cell?

Community
  • 1
  • 1
marlenunez
  • 626
  • 4
  • 9
  • 1
    I like the version from your edit, much easier to copy/paste that code into the VBA interface and have it work – tech_geek23 Jun 03 '13 at 03:49
  • The only issue I've come across is if I use double or triple digit numbers, it only references off the first digit – tech_geek23 Jun 03 '13 at 04:20
  • 1
    I see. It is treating the values as text. Declare `pivot` as `Long` in the QuickSort sub. `Dim pivot As Long`. Change this also: `pivot = CLng(vArray((inLow + inHi) \ 2))`. It will treat your values as numbers now. – marlenunez Jun 03 '13 at 14:22