CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2014
    Posts
    1

    DateDiff assistance

    So I need some help debugging some code. I'm trying to create a macro that updates the years since a date that is given in column 16 of each row then placing that number of years in row Sub dateUpD8()
    x = 3
    Do Until Cells(x, 16).Value = ""
    d = Cells(x, 16).Value
    fromDate = CDate(d)
    toDate = CDate(Now)
    Cells(x, 27).Value = DateDiff("y", fromDate, toDate)
    x = x + 1
    Loop
    End Sub


    What am I doing wrong?

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: DateDiff assistance

    Try
    Code:
    Cells(x, 27).Value = DateDiff("yyyy", fromDate, toDate)
    Else maybe you should tell us what problem you are having.
    Always use [code][/code] tags when posting code.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured