Sorting by date formula with both numerical values and text values

  • Hi All,

    I've come across a road block. The sorting code I have works well only with numerical figures (5/1/2011). How can I make it work with both text ( Early May) and numerical (5/1/2001)figures? for example, here what I have so far:



    Now I need to also tell excel to sort if the dates entered happen to be, for example, Early May, Mid May or Late May. How can I get the formula to tell excel that if a numerical date is entered the the specified cells ( 5/23/2011) sort date, however if only text is entered (Late May) sort alphabetically by that entry as well.
    Can this be done? If so, how? Can you please help me with this? Thank you!

  • Re: Sorting by date formula with both numerical values and text values


    Can you give an example of data, pre-sorting and post-sorting to show what you mean? As you seem to be saying that you want it sorted numerically for dates and alphabetically for text, which is what Excel does anyway ... e.g.

    Dates
    01/01/2011
    07/01/2011
    13/01/2011
    19/01/2011
    25/01/2011
    31/01/2011
    06/02/2011
    12/02/2011
    18/02/2011
    24/02/2011
    08/03/2011
    14/03/2011
    20/03/2011
    07/04/2011
    19/04/2011
    13/05/2011
    Early April
    Early March
    Early May
    Late April
    Late March
    Late May
    Mid April
    Mid May

    ... I'd say that you want to translate such entries into real dates, in another column, and sort on that, 'cos I'd guess that alphabetically isn't going to be what you want.

    Cheers, Glenn.


    Beauty is in the eye of the beer-holder.

  • Re: Sorting by date formula with both numerical values and text values


    Hi,

    Thank you so much for replying to my inquiry. I have attached a sample of my work below. I would like it to be sorted numerically first. e.g.:
    5/1/2011
    5/5/2011
    5/6/2011
    Early May
    Late May
    Mid May

    Please see the attached file (below) named "Sample". Hopefully this will make things a bit clearer. I hope you can help me with this.

    forum.ozgrid.com/index.php?attachment/38948/

  • Re: Sorting by date formula with both numerical values and text values


    You've password protected the VBA project, and I'm getting a Type Mismatch crash in macro.

    In your latest posting example you show data from a single month ( assuming US date format ) ... is the sorting to be for a single month? If so, it should sort fine anyway, I would guess.

    Cheers, Glenn.


    Beauty is in the eye of the beer-holder.

  • Re: Sorting by date formula with both numerical values and text values


    Hi Glenn,

    I've sent you an email with the password.

    The sorting will be for all the months within the year. I just used May as an example. Currently the sorting works when the date is added numerically (e.g. 5/1/2011) but I want, when there is no exact date, to be able to put the words "Early May", Late May or "Mid May" and have that be sorted alphabetically all at the same time the other dats are being sorted numerically. That is why there is a type mismatch--becasue I havent got the right code to tell excel to sort the text dates while sorting the numeric dates.

  • Re: Sorting by date formula with both numerical values and text values


    Can anyone help with my inquiry? Is it possible to sort numerically and alphabetically?

  • Re: Sorting by date formula with both numerical values and text values


    Quote from Brand_New2VBA;560073

    Hi Glenn,


    I've sent you an email with the password.


    The sorting will be for all the months within the year. I just used May as an example. Currently the sorting works when the date is added numerically (e.g. 5/1/2011) but I want, when there is no exact date, to be able to put the words "Early May", Late May or "Mid May" and have that be sorted alphabetically all at the same time the other dats are being sorted numerically. That is why there is a type mismatch--becasue I havent got the right code to tell excel to sort the text dates while sorting the numeric dates.


    I've received no note or mail. Keeping the password secret means that no-one else can help you either ... why aren't you just telling the password here?

    Cheers, Glenn.


    Beauty is in the eye of the beer-holder.

  • Re: Sorting by date formula with both numerical values and text values


    Thank you. I will look at this when I'm free.

    Of course, now others on here may be able to help you too.

    Cheers, Glenn.


    Beauty is in the eye of the beer-holder.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!