1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Writing Macros in Word

Discussion in 'BBS Hangout' started by fallenphoenix, Apr 17, 2013.

  1. fallenphoenix

    fallenphoenix Member

    Joined:
    Jun 20, 2009
    Messages:
    9,821
    Likes Received:
    1,620
    Anyone good at it? Essentially my boss wants me to write a macro that calculates the years and months between a given date and today's date. i know how to write the formula in excel, but he wants it to be functional in a table in word.

    edit: actually i'm not even sure how to write that in excel, i only know how to do it to calculate months, not years and months
    example: =(YEAR(NOW())-YEAR(E3))*12+MONTH(NOW())-MONTH(E3)

    Any help would be appreciated.
     
  2. Ricksmith

    Ricksmith Member

    Joined:
    May 6, 2009
    Messages:
    6,299
    Likes Received:
    613
  3. arkoe

    arkoe (ง'̀-'́)ง

    Joined:
    Dec 13, 2001
    Messages:
    10,388
    Likes Received:
    1,599
    Modified formula from Microsoft.

    =YEAR(TODAY())-YEAR(E3)-IF(OR(MONTH(TODAY()) < MONTH(E3),AND(MONTH(TODAY())=MONTH(E3), DAY(TODAY())< DAY(E3))),1,0)&" years, "&MONTH(TODAY())-MONTH(E3)+IF(AND(MONTH(TODAY()) <=MONTH(E3),DAY(TODAY())< DAY(E3)),11,IF(AND(MONTH(TODAY()) < MONTH(E3),DAY(TODAY()) >= DAY(E3)),12,IF(AND(MONTH(TODAY())> MONTH(E3),DAY(TODAY()) < DAY(E3)),-1)))&" months, "&TODAY()-DATE(YEAR(TODAY()),MONTH(TODAY())-IF(DAY(TODAY()) < DAY(E3),1,0),DAY(E3))&" days"

    I don't get what you would want a macro to process/do or how this would be applicable to Word.
     
    #3 arkoe, Apr 17, 2013
    Last edited: Apr 17, 2013

Share This Page