+ Reply to Thread
Results 1 to 21 of 21

Date When Certain Amount of Text Occurs

  1. #1
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Date When Certain Amount of Text Occurs

    Hi. I am trying to create a formula which would display a date (prior to the computer's system time) when a certain amount of text occurs.

    I have attached my workbook with an example and further explanation.
    Attached Files Attached Files

  2. #2
    Forum Contributor amit.wilson's Avatar
    Join Date
    07-09-2013
    Location
    Gotham
    MS-Off Ver
    Excel for Mac 2011
    Posts
    283

    Re: Date When Certain Amount of Text Occurs

    Hi, try this

    C1: =IF(AND(B1="a",COUNTIF($B$1:B1,"a")=3,A1<TODAY()),A1,"")

    Copy C1 and copy it down the column. You should see the formulas like this:

    C2: =IF(AND(B2="a",COUNTIF($B$1:B2,"a")=3,A2<TODAY()),A2,"")
    C3: =IF(AND(B3="a",COUNTIF($B$1:B3,"a")=3,A3<TODAY()),A3,"")
    ... etc


    This will show the date from column A only when both conditions are met, the 3rd 'a' occurs and the date in column A is less than the current date.

    Cheers
    <-- If you're happy & you know it...click the star.:-)

  3. #3
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    Thanks, but I would only like to have 1 formula which would count the occurrence of a's in a range of cells (B1:B7), instead of just one cell (B1).

    Is this possible?

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Date When Certain Amount of Text Occurs

    Try this.......

    Please Login or Register  to view this content.
    Is this what you want?
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    Unfortunately, that formula displays the computer's system time.

    I need the formula to display the date (from column A) when the 3rd "a" occurs prior to the computer's system time.

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Date When Certain Amount of Text Occurs

    Do you want this output?

    Please Login or Register  to view this content.
    Copy it down as far as it is needed.

  7. #7
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    That formula, like the one in post #2, also looks at one row of cells (A1 and B1).

    The formula should look at a range of cells (A1:A7 and B1:B7).

  8. #8
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Date When Certain Amount of Text Occurs

    Do you want the formula to display date when the 3rd occurrence of "a" took place very first time in the range? Or you want formula to display date of column A every time when it finds every 3rd occurrence of "a" in column B? I think you are not able to explain your requirement well.

    It would be better if you upload a sample workbook with two sheets, Before and After. Where in the Before sheet you just simply put some sample data and in After sheet, you put the complete desired output applicable to the whole data set of Before sheet.

    The formula I gave you will look the first 3rd occurrence of "a" in col. B and then display the corresponding col. A date in corresponding cell in col. C. Then it goes further and once it finds next 3rd occurrence of "a" in col. B, it displays the corresponding col. A date in the corresponding cell in col. C.
    Was that not your requirement?

  9. #9
    Forum Contributor amit.wilson's Avatar
    Join Date
    07-09-2013
    Location
    Gotham
    MS-Off Ver
    Excel for Mac 2011
    Posts
    283

    Re: Date When Certain Amount of Text Occurs

    jhudson444 - finding the 1st instance of a text is easy using VLookup(). But finding the 2nd, 3rd,..., nth instance is a little complicated.

    If you want all the calculation to take place in one cell, then using a macro/VBA code would be the best and easiest way.

    But if you don't mind the calculation spread over a few cells, try using the attached excel.

    You'll see that I've moved the columns around (A has become B and B has become A) to make the VLookup work.

    Let me know if this works for you.

    Cheers
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    Quote Originally Posted by sktneer View Post
    Do you want the formula to display date when the 3rd occurrence of "a" took place very first time in the range? Or you want formula to display date of column A every time when it finds every 3rd occurrence of "a" in column B?
    Yes, I want the formula to display the date of column A every time it finds every 3rd occurrence of "a" in column B (it should display the first date of occurrence prior to the computer's date).

    Quote Originally Posted by amit.wilson View Post
    jhudson444 - finding the 1st instance of a text is easy using VLookup(). But finding the 2nd, 3rd,..., nth instance is a little complicated.

    If you want all the calculation to take place in one cell, then using a macro/VBA code would be the best and easiest way.
    Yes, I would like the calculation to take place in one cell. I don't know how to use a macro/VBA code.

    I've attached a new workbook with 4 sheets to better explain what the formula should do. I hope this helps. Thanks for trying to help, everyone.
    Attached Files Attached Files
    Last edited by jhudson444; 11-10-2013 at 07:37 PM.

  11. #11
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Date When Certain Amount of Text Occurs

    try this UDF (User Defined Function) i created:

    Please Login or Register  to view this content.
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    the arguments i placed for this function are the Range required, to count what text, and how many times you require the count to be

    so that means in Sheet1, i used:
    =GetDate(A1:A7,"a",3)

    if it's always "a" & 3 counts, you can use this:
    Please Login or Register  to view this content.
    then just:
    =GetDate2(A1:A7)

    i am always interested in non-VBA ways, so let me ask if someone awesome can help chip in.

    ps: you have to enable macros if you try my file
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  12. #12
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Date When Certain Amount of Text Occurs

    I lol for this idea i had .
    helper column for character count then multiple if statement for index /sumproduct (last entry,2nd to last,3rd to last...) .
    look attachment.

    jhudsonvlad.xlsx
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  13. #13
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    Quote Originally Posted by benishiryo View Post
    try this UDF (User Defined Function) i created:
    I was unable to get your function to work (I enabled macros when I opened your workbook).

    Quote Originally Posted by vlady View Post
    I lol for this idea i had .
    helper column for character count then multiple if statement for index /sumproduct (last entry,2nd to last,3rd to last...) .
    look attachment.
    This formula worked to calculate a correct date:

    Please Login or Register  to view this content.
    This formula worked to calculate 2 months (with the first day of the month) after that correct date:

    Please Login or Register  to view this content.
    Two issues:

    1. Is there a way to make the first formula work without needing a "helper column"?

    2. Is there a way to combine these two formulas?

    I've attached a modified workbook (see orange/yellow highlight on sheet 1).
    Attached Files Attached Files

  14. #14
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Date When Certain Amount of Text Occurs

    I can't think a way NOT to have the helper column there, you can hide the column or use other column that is far from those data say column Z.

    to combine the two formula
    =EOMONTH(the first long formula here,2)+1


    BTW the UDF works fine on my side.. and it's shorter.

  15. #15
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Date When Certain Amount of Text Occurs

    a shorter version provided by our friends. BUT still with the helper there.
    array..

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    hope someone could help further analyze on applying a formula without helper column.

  16. #16
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    Quote Originally Posted by vlady View Post
    I can't think a way NOT to have the helper column there, you can hide the column or use other column that is far from those data say column Z.
    Ok, thanks for the help.

    The problem with the helper column is that I don't want to make an entry into column C every time I make an entry into column B.

    Hopefully, someone can figure out how to modify the first formula in post #13 (or just create an entirely new formula) to not include a helper column.

  17. #17
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Date When Certain Amount of Text Occurs

    using post #13 formula
    array entered i came up with this without helper column.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    edited above::: due to last statement c1:c9
    you can include your eof the just as in post #14

    i don't know if I can do it in offset though. post #15

    I don't want to make an entry into column C every time I make an entry into column B
    the helper cells are formulas no need to enter then just drag them all the way down as you want.
    Last edited by vlady; 11-12-2013 at 10:26 PM.

  18. #18
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    Thanks!

    The formula now counts the occurrence of any text in column B. Is there a way to make it count the occurrence of specific text (count "a" or "b")?

  19. #19
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Date When Certain Amount of Text Occurs

    look below attachment


    jhudsonvlad3rd.xlsx

  20. #20
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    Thank you!

    Two more things, and I think my problem will be solved:

    1. Can you tell me how to modify the formula to look for 6 occurrences (>=6) instead of 3?

    2. Can you tell me how to make the formula also look for "b"?
    Last edited by jhudson444; 11-14-2013 at 06:50 PM.

  21. #21
    Registered User
    Join Date
    08-20-2013
    Location
    Schenectady, NY
    MS-Off Ver
    Excel 2011 Mac
    Posts
    64

    Re: Date When Certain Amount of Text Occurs

    Quote Originally Posted by jhudson444 View Post
    Thank you!

    Two more things, and I think my problem will be solved:

    1. Can you tell me how to modify the formula to look for 6 occurrences (>=6) instead of 3?

    2. Can you tell me how to make the formula also look for "b"?
    Array formula (note: this formula has a limit to how much text it can index before "Formula is too long" error occurs -- I think up to "e" or "f" is as much as it can index):
    Please Login or Register  to view this content.
    Thanks for the help, everyone!

+ 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: 3
    Last Post: 08-04-2013, 09:40 PM
  2. Replies: 2
    Last Post: 04-28-2013, 02:23 AM
  3. How to match Date and Amount from Sheet1 to Sheet2 with the same Date and Amount?
    By ims0phie in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-23-2013, 06:51 AM
  4. Count X amount of numbers between #1 occurs
    By slk704 in forum Excel General
    Replies: 5
    Last Post: 11-08-2010, 07:24 AM
  5. getting the amount from between text and a date
    By darkhangelsk in forum Excel General
    Replies: 32
    Last Post: 08-28-2009, 09:51 PM

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