+ Reply to Thread
Results 1 to 3 of 3

If & elseif stuggle

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    notts
    MS-Off Ver
    365
    Posts
    24

    If & elseif stuggle

    Hi guys,

    Wondering if anyone can point me in the right direction on this one.

    Dim DOTW
    Dim Time

    DOTW pulls a day as text from a cell, e.g Wednesday, Friday etc
    Time pulls a time serial as text from a cell formatted as 'Time' e.g 12:48:17

    Code I have is:
    Please Login or Register  to view this content.
    However it only seems to check against the DOTW and not the Time conditional, and only seems to work for the first If statement, if this is true it adjusts the date correctly for the delay on the email, however if its any of the other variables below the first Elseif it still uses that deferral setting.

    E.g, if its Wednesday, 12:20:22, it should set the delay for 4pm same day, but it always sets it for 3 days time, even through the DOTW does not = Friday.

    Aditionally, >= & <= don't seem to work for the check against the Time, so if its after 3pm and it should defer to the next day it still sets it for today. Is this because of the XX:XX:XX format?

    Any help greatly appreciated!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: If & elseif stuggle

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    notts
    MS-Off Ver
    365
    Posts
    24

    Re: If & elseif stuggle

    Hi,

    example attached with macro included, running this should generate the email with generic info.

    On a slightly related note, .SentOnBehalfName has stopped working since we moved to Outlook 2010. The email address is a shared mailbox and worked fine before (2003 I believe) but now wont pull the email even if its available in the drop down selection manually. I have looked into this before but not managed to find any solutions so if someone can shed any light on this one shout up

    EDIT: Hang fire, I've mucked up this attachment, editing now!

    EDIT 2: Fixed, apologies. Note, when you run the macro it shifts some cells around and hides a column so re-running the macro a second time wont work, needs closing and re-opening. Poor design on my part but we never need to run it more than once here but need to hide that column to keep the data available but unseen.
    Attached Files Attached Files
    Last edited by promithius; 04-16-2015 at 07:51 AM.

+ 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. If / ElseIf within For Each?
    By pwells in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2014, 10:35 AM
  2. Dissertation stuggle
    By Khadilynam in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-27-2014, 10:59 AM
  3. Code stepping in to elseif statement when elseif is definitely not true
    By DFrank231 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-13-2013, 05:31 PM
  4. If Elseif elseif problem
    By tjbillund in forum Excel General
    Replies: 3
    Last Post: 08-10-2011, 07:02 AM
  5. if elseif
    By flow23 in forum Excel General
    Replies: 0
    Last Post: 11-14-2005, 10:15 AM

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