+ Reply to Thread
Results 1 to 5 of 5

Formula to insert text in a cell based on the date range of another cell

  1. #1
    Registered User
    Join Date
    03-28-2016
    Location
    Coventry
    MS-Off Ver
    Microsoft 365
    Posts
    65

    Formula to insert text in a cell based on the date range of another cell

    Hi guys,


    Basically, I have my home budget workbook which has a column for "pay date" which I usually enter text into, for example 16th to represent the date of that required payment. in the next column, I want the cell to populate the initials of the person to pay the bill dependant on when the date is.

    any payments that fall on, or between the 15th of the month to the 25th of the month is covered by my wife, anything from the 26th to the 14th of the next month is covered by myself.

    I want excel to recognise this and auto populate the adjacent cell based on these date ranges. I tried the IF function in a few different ways but cant seem to get it to work? I think it maybe the way I insert the date as general text?

    My current formula looks like this but doesn't work?

    =IF(AND(Q17>="15th",Q17<="25th"),"CJ"=IF(AND(Q17>="26th",Q17<="14th"),"DJ",""))

    Just wondering if their is a better way to get the result I want.

    Capture.PNG


    The cell ref for the formula is T17. I would appreciate any help with this.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,604

    Re: Formula to insert text in a cell based on the date range of another cell

    If you remove sufix from your numbers then it will work:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    keep it simple

  3. #3
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Formula to insert text in a cell based on the date range of another cell

    Try this ...

    =IF(Q17="","",IF(AND(LEFT(Q17,2)+0>=15,LEFT(Q17,2)+0<=25),"CJ","DJ"))

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to insert text in a cell based on the date range of another cell

    Quote Originally Posted by zbor View Post
    =IF(AND(Q17>=15,Q17<=25),"CJ"=IF(AND(Q17>=26,Q17<=14),"DJ",""))
    Q17 can not be >=26 AND <=14 at the same time!

    Maybe you meant OR:

    =IF(AND(Q17>=15,Q17<=25),"CJ",IF(OR(Q17>=26,Q17<=14),"DJ",""))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,604

    Re: Formula to insert text in a cell based on the date range of another cell

    Nice spoted Tony. Didn't analyze numbers.

    However, in that case doesn't need second IF (except if it's blank, probably).
    If it's not between 15 and 25 then it's rest.

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

+ 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. [SOLVED] VBA to insert text based on cell in range
    By Burt_100 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-11-2016, 10:50 AM
  2. Replies: 6
    Last Post: 04-15-2015, 10:25 PM
  3. lock and insert formula in a cell based on selection of text in another cell
    By alirazafazal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2014, 06:08 AM
  4. Formula to identify part of a text in cell from range of cells & insert adjacent cell text
    By Novicebutnotforlong in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 11-19-2013, 02:11 AM
  5. [SOLVED] Event Macro to insert text in cell based on input of another cell
    By nplouffe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-08-2012, 11:54 AM
  6. Replies: 1
    Last Post: 03-16-2011, 11:05 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