+ Reply to Thread
Results 1 to 5 of 5

Trouble adding day to today's date

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

    Trouble adding day to today's date

    I need to return in column H today's date plus 2 days when Z has "Transport to STK / FORN" as value. But instead of bringing 2 days added to today, it brings me value of column AW.

    i tryed "Date + 2" and "DateAdd(w, 2, Date)" none of them work.


    Code:
    Sub UpdateColumnH()

    Dim rw As Long, LR As Long

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

    For rw = 3 To LR
    If IsDate(Range("H" & rw)) Then
    'do nothing
    ElseIf Not IsDate(Range("AW" & rw)) Then
    'do nothing
    ElseIf UCase(Range("J" & rw).Value) = "Date Set" Then
    'do nothing
    ElseIf UCase(Range("I" & rw).Value) = "CONTROL" Then
    Range("H" & rw).Value = Range("AW" & rw).Value
    ElseIf UCase(Range("Z" & rw).Value) = "Transport to STK / FORN" Then
    Range("H" & rw).Value = DateAdd(w, 2, Date) 'Date + 2
    Else
    Range("H" & rw).Value = Range("AW" & rw).Value
    End If
    Next rw

    End Sub

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,175

    Re: Trouble adding day to today's date

    Change

    ElseIf UCase(Range("Z" & rw).Value) = "Transport to STK / FORN" Then

    to

    ElseIf Range("Z" & rw).Value = "Transport to STK / FORN" Then

    or

    ElseIf UCase(Range("Z" & rw).Value) = "TRANSPORT TO STK / FORN" Then

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

    Re: Trouble adding day to today's date

    None fo them work =/

  4. #4
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Trouble adding day to today's date

    Lu,

    Can you pls put an excel to your conversation?

    Also please use the code tags while posting a code. They are marked with the hash sign "#".
    Please consider:
    Be polite. Thank those who have helped you.
    Click the star icon in the lower left part of the contributor's post and add Reputation. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Posting code between tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Trouble adding day to today's date

    Try this
    Change
    Please Login or Register  to view this content.
    as
    Please Login or Register  to view this content.

+ 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. [SOLVED] Going to a specific column and adding today's date
    By backyardfun in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-16-2015, 09:24 AM
  2. [SOLVED] Adding 4 days into the date today minus the weekend
    By geliedee in forum Excel General
    Replies: 5
    Last Post: 05-22-2015, 09:44 AM
  3. Change date into text if <today and adding text if cell isblank... into an Array.
    By JasonNeedsHelp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-29-2013, 12:06 PM
  4. [SOLVED] Adding Today's Date to a Filename
    By longbow007 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-06-2012, 08:51 PM
  5. Help adding VBA code to existing macro to select "today's" date
    By kennected in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2012, 09:21 PM
  6. Adding values reference to date today
    By xmoore in forum Excel General
    Replies: 5
    Last Post: 12-14-2009, 11:39 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