+ Reply to Thread
Results 1 to 3 of 3

subtract business from date in a cell

  1. #1
    Registered User
    Join Date
    06-21-2016
    Location
    Brazil
    MS-Off Ver
    2002
    Posts
    23

    subtract business from date in a cell

    Here in this code I put a condition, and if the condition is met, I subtract 2 days from the date in cell "Q". But i wanted to know if i can subtract two WORKDAYS, instead of normal days.

    *It needs to use weekday function, because i use excel 2002, and it does not have workdayfunction.



    If Range("AW" & rw).Value >= Range("Q" & rw).Value Then
    Range("AZ" & rw).Value = Range("Q" & rw).Value - 2
    Range("AZ" & rw).Select
    With Selection.Interior
    .ColorIndex = 35
    .Pattern = xlSolid
    End With

  2. #2
    Registered User
    Join Date
    06-21-2016
    Location
    Brazil
    MS-Off Ver
    2002
    Posts
    23

    Re: subtract business from date in a cell

    Here's the whole code.

    LR = Range("A" & Rows.Count).End(xlUp).Row

    For rw = 3 To LR
    If IsEmpty(Range("AW" & rw).Value) Then
    Range("AW" & rw).Value = Date
    Range("AW" & rw).Select
    With Selection.Interior
    .ColorIndex = 15
    .Pattern = xlSolid
    End With
    End If


    If Range("AW" & rw).Value >= Range("Q" & rw).Value Then
    Range("AZ" & rw).Value = Range("Q" & rw).Value - 2
    Range("AZ" & rw).Select
    With Selection.Interior
    .ColorIndex = 35
    .Pattern = xlSolid
    End With

    ElseIf Range("AW" & rw).Value < Range("Q" & rw).Value Then
    Range("AZ" & rw).Value = Range("AW" & rw).Value
    Range("AZ" & rw).Select
    With Selection.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With


    ElseIf Not IsEmpty((Range("H" & rw).Value)) Then
    Range("BA" & rw).Value = "Data prazo já existente, Conferir."

    End If
    Next rw
    End Sub

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: subtract business from date in a cell

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

+ 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. business date cell copying issue
    By mcronin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2016, 11:17 AM
  2. Pass the last business days date through odbc to "select where date >= the date"
    By MostHated in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-29-2015, 04:15 PM
  3. [SOLVED] Need FORMULA for Date subtract Date equal bussiness hour (don't count weekend)
    By tuongtu3 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-24-2015, 03:29 AM
  4. how to calculate the 15th business date from starte date
    By sagayastalin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2014, 09:20 AM
  5. Cell Formula to subtract 1 day from date
    By chris1965 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-19-2013, 08:04 PM
  6. Replies: 0
    Last Post: 03-21-2013, 12:22 PM
  7. Excel 2007 : Subtract a cell based on current date
    By nfavours in forum Excel General
    Replies: 2
    Last Post: 11-08-2011, 06:03 PM

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