+ Reply to Thread
Results 1 to 6 of 6

Compare Dates, post status as text string

  1. #1
    Registered User
    Join Date
    10-19-2018
    Location
    Austin, Texas
    MS-Off Ver
    Professional Plus 2013
    Posts
    8

    Compare Dates, post status as text string

    I am trying to jazz up a work status spreadsheet so that it automatically indicates whether a particular status "met expectations" or "achieved excellence" based on the date by which the task was completed.
    I have one column for the "Meet Expectations" target date, one column for the "Achieve Excellence" target date, and one column for "Date Completed".

    I am attempting to write a macro that will read the date completed, then compare it to the other two dates. If date complete is on or before Meet Expectations, but after Achieve Excellence, then the Results column should return "Met Expectations".

    If date complete is on or before Achieve Excellence, then the Results column should return "Achieved Excellence".

    I have written this so far:

    Sub CalculateResults()
    If (D20 <= C20) Then
    F20 = "Achieved Excellence"
    ElseIf (D20 > C20 And D20 <= B20) Then
    F20 = "Met Expectations"
    End If
    End Sub

    But it doesn't seem to be doing anything.

    My file is attached.

    Thanks,
    Henry
    Attached Files Attached Files

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Compare Dates, post status as text string

    Please use code tags as per forum rules.

    That said, D20 in VBA is just a variable name... if you mean Cell D20's value then you refer to it as a range (and usually safest to include the sheet context also):


    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Compare Dates, post status as text string

    One method
    Please Login or Register  to view this content.
    Add into a Module
    Attached Files Attached Files
    Last edited by nigelog; 10-19-2018 at 12:21 PM.

  4. #4
    Registered User
    Join Date
    10-19-2018
    Location
    Austin, Texas
    MS-Off Ver
    Professional Plus 2013
    Posts
    8

    Re: Compare Dates, post status as text string

    Thank you! Helped me understand what I did not do right.

  5. #5
    Registered User
    Join Date
    10-19-2018
    Location
    Austin, Texas
    MS-Off Ver
    Professional Plus 2013
    Posts
    8

    Re: Compare Dates, post status as text string

    Awesome! Took the request to the logical conclusion to apply to all cells. Will study this to see what I didn't get right the first time.

  6. #6
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286
    No problems, you might need some other form of error checking. This just moves to the next row if no date in column c. Ta for marking as 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. Compare string of text different sheets
    By a1b2c3d4e5f6g7 in forum Excel General
    Replies: 3
    Last Post: 02-25-2015, 12:13 PM
  2. [SOLVED] Compare two adjacent text cells and then provide a status in a 3rd cell
    By Avalonexile in forum Excel General
    Replies: 2
    Last Post: 02-06-2015, 08:45 AM
  3. Function to return status text based on dates
    By jscalem in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-24-2014, 04:48 PM
  4. Compare multiple values in other text string
    By morsoe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-30-2013, 06:41 AM
  5. Replies: 4
    Last Post: 04-08-2012, 09:43 PM
  6. Compare and Populate Approximate Text String
    By Kumara_faith in forum Excel General
    Replies: 2
    Last Post: 02-27-2011, 02:40 AM
  7. Excel 2007 : Compare text string with cell range
    By LST in forum Excel General
    Replies: 1
    Last Post: 12-15-2010, 08:43 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