+ Reply to Thread
Results 1 to 7 of 7

Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA

    Hi.
    I'd like your help to do the following.
    I have two TextBox. The TextBox1, I enter a date (dd / mm / yyyy) in TextBox2 I would like the results as "Y", starting from today.

    example:
    TextBox1 = 30/05/1990 TextBox2= 22


    I tried it but did not work!
    Please Login or Register  to view this content.

    if someone could help me will be grateful!

    Thank you!
    Last edited by marreco; 06-07-2012 at 11:41 AM.
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  2. #2
    Forum Contributor tkowal's Avatar
    Join Date
    11-20-2010
    Location
    Miami, Fl
    MS-Off Ver
    Excel 2010
    Posts
    150

    Re: Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA

    The Change event evaluates each keystroke so you will need to use an event to do the calculation "after the date has completely been entered". I used the "LostFocus" event in the code snippet below. After you change textbox1 with the date, click anywhere outside the box and textbox2 will calculate to the difference in Years between now and the date entered in Textbox 1

    note that you could use a button to trigger the calculation as well....

    Please Login or Register  to view this content.
    Enjoy!
    Last edited by tkowal; 06-07-2012 at 11:27 AM. Reason: Little grammar corrections
    Ted
    "Live Long and Prosper"

  3. #3
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA

    Hi.
    Thank you!!!

    was great!!

    Thank you!!!

  4. #4
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA

    I wonder if you can do this without using a CommandButton?
    after digitarr date in textbox1, the move to textbox2, cóodigo run, is this possible?

  5. #5
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA

    Hi
    Any idea?
    wonder if you can do this without using a CommandButton?
    after digitarr date in textbox1, the move to textbox2, cóodigo run, is this possible?

  6. #6
    Forum Contributor tkowal's Avatar
    Join Date
    11-20-2010
    Location
    Miami, Fl
    MS-Off Ver
    Excel 2010
    Posts
    150

    Re: Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA

    There would be no easy way to do that without very advanced programming to create your event.

    The easiest way without a command button I can think of is processing when you hit the Enter Key after typing in your date.

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA

    was great, thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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