+ Reply to Thread
Results 1 to 6 of 6

Insert a number with "st", "nd","rd","th"

  1. #1
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Insert a number with "st", "nd","rd","th"

    In my worksheet I have the following:

    A2 is a date e.g. 01Jan20 to 31Dec20
    B2 is the day of the week based on A2 e.g. Mon or Wed or Sun. Formula in this cell is =TEXT(WEEKDAY(A2), "ddd")
    C3 is the occurrence of that day in any given month, based on A2 e.g. 1 or 2 or 3 or 4 or 5 ie the first wednesday of a month or second wednesday of a month or fifth friday of a month etc. Formula in this cell is: =INT((DAY(A2)-1)/7)+1

    Examples of data are:

    01Jan20 Wed 1
    08Jan20 Wed 2
    31Jan20 Fri 5
    01Feb20 Sat 1
    08Feb20 Sat 2
    31Dec20 Thu 5

    I have been able to identify which days of month, in a new column - D3, are "st", "nd","rd","th" with the following formula =LOOKUP(DAY(A2),{1,"st";2,"nd";3,"rd";4,"th";21,"st";22,"nd";23,"rd";24,"th";31,"st"})

    01Jan20 Wed 1 st
    08Jan20 Wed 2 nd
    31Jan20 Fri 5 th
    01Feb20 Sat 1 st
    08Feb20 Sat 2 nd
    31Dec20 Thu 5 th

    But this hasn't helped as the formula identifies which days of week are; "st", "nd","rd","th" and not the "occurrence of that day" in any given month. (if that makes sense)

    The result I am looking for is as follows;

    01Jan20 Wed 1 1st
    08Jan20 Wed 2 2nd
    31Jan20 Fri 5 5th
    01Feb20 Sat 1 1st
    08Feb20 Sat 2 2nd
    31Dec20 Thu 5 5th


    I trust the above makes some sense and thank you for your time and consideration.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Insert a number with "st", "nd","rd","th"

    How about
    =DAY(A2)&LOOKUP(DAY(A2),{1,"st";2,"nd";3,"rd";4,"th";21,"st";22,"nd";23,"rd";24,"th";31,"st"})

  3. #3
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Re: Insert a number with "st", "nd","rd","th"

    Thank you for the quick response much appreciated. However, the solution you propose does not appear to give the desired result. I do get day of week and the appropriate "st", "nd","rd","th" but
    the solution I am looking for is;

    01Jan20 Wed 1 so the 1 is appended with st. This the first Wednesday in Jan. Required Result 1st
    etc
    08Jan20 Wed 2 so the 2 is appended with nd. This is the second Wednesday in Jan. Requested Result 2nd
    etc
    31Jan20 Fri 5 so the 5 is appended with th. This is the fifth Friday in Jan. Required Result 5th
    01Feb20 Sat 1 so the 1 is appended with st. This is the first Saturday in Feb. Required Result 1st
    etc
    08Feb20 Sat 2 so the 2 is appended with nd. This is the second Saturday in Feb. Required Result 2nd
    etc...
    31Dec20 Thu 5 so the 5 is appended with th. This is the fifth Thursday in Dec. Required Result 5th

    So the required "st", "nd","rd","th" are based upon 1 or 2 or 5 or 1 or 2 or 5 in the desired solution and not on the actual day of month.

    Thank you again for your time and patience.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Insert a number with "st", "nd","rd","th"

    In that case, how about
    =C2&LOOKUP(C2,{1,"st";2,"nd";3,"rd";4,"th";21,"st";22,"nd";23,"rd";24,"th";31,"st"})

  5. #5
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Smile Re: Insert a number with "st", "nd","rd","th"

    Perfect. Thank you so much for your time. All worked ok. This thread can now be closed.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Insert a number with "st", "nd","rd","th"

    You're welcome & thanks for the feedback.

    Tomark the thread as sloved, please select Thread Tools from the menu link above the OP and select SOLVED.

+ 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. Replies: 5
    Last Post: 02-05-2019, 12:03 AM
  2. Replies: 3
    Last Post: 05-02-2018, 08:03 AM
  3. Replies: 2
    Last Post: 07-24-2017, 02:19 AM
  4. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  5. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM

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