Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    calculate only workday (2000 sr 1)

    i have this line of code
    ELENCO.Range("K" + RIGA) = CDate(Now) - CDate(ELENCO.Range("A" + RIGA))

    is ######ible to consider only a work day in range "A"

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: calculate only workday (2000 sr 1)

    I don't understand.

    If the value in ELENCO.Range("A" + RIGA) is not a workday, what do you want to do?

    You can use the Weekday function to get the day of the week and use a case structure (change the code to do what you want when the date is a saturday or sunday.
    <pre>Dim dDate As Date


    dDate = CDate(ELENCO.Range("A" & RIGA))
    Select Case Weekday(dDate)
    Case vbMonday To vbFriday
    ELENCO.Range("K" & RIGA) = _
    CDate(Now) - dDate
    Case vbSaturday
    ELENCO.Range("K" & RIGA) = "Saturday"
    Case vbSunday
    ELENCO.Range("K" & RIGA) = "Sunday"
    End Select</pre>


    Steve

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: calculate only workday (2000 sr 1)

    ... tks for code...
    I import this data from a application each day in my office, and sure the value in range A are sure a work days...
    Just queestion!
    Tks.

Posting Permissions

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