+ Reply to Thread
Results 1 to 7 of 7

Compare to toadys date

  1. #1
    Registered User
    Join Date
    02-07-2010
    Location
    Manchesteer
    MS-Off Ver
    Excel 2007
    Posts
    51

    Compare to toadys date

    hi,

    I'm very new to VBA and I want to write a simple if statement like this:

    If date (in cell D18) is equal to (today's date)
    then do (code)

    So what i have tried is this:

    Please Login or Register  to view this content.
    This hasn't worked - any advice?

    Thanks,
    Mark

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Compare to toadys date

    Try:
    Please Login or Register  to view this content.
    I added CLng in case you have time values in there too.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Compare to toadys date

    Try this
    Please Login or Register  to view this content.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  4. #4
    Registered User
    Join Date
    02-07-2010
    Location
    Manchesteer
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Compare to toadys date

    Quote Originally Posted by romperstomper View Post
    Try:
    Please Login or Register  to view this content.
    I added CLng in case you have time values in there too.
    Not working... here's all my code:

    Please Login or Register  to view this content.
    Thanks,
    Mark

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Compare to toadys date

    What specifically do you mean by 'not working'? The code itself is fine, so seeing a sample workbook might be helpful.

  6. #6
    Registered User
    Join Date
    02-07-2010
    Location
    Manchesteer
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Compare to toadys date

    Quote Originally Posted by romperstomper View Post
    What specifically do you mean by 'not working'? The code itself is fine, so seeing a sample workbook might be helpful.
    It says variable not defined - not sure which variable? anyway - workbook attached...

    Thanks,
    MArk
    Attached Files Attached Files

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Compare to toadys date

    That's because in this line:
    Please Login or Register  to view this content.
    you had typed x1up rather than xlup...

+ 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