+ Reply to Thread
Results 1 to 2 of 2

VBA for long if formula

  1. #1
    Registered User
    Join Date
    07-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    VBA for long if formula

    I have a template that looks for a date in serveral different columns and if found, adds five days to show an estimated stock date. my exported report gives the dates as follows 1130813 so that needs formatted as well. so I've come up with this massive ugly formula that causes my computer to freeze for a quite a period of time. not good with VBA and was hoping if something could be written for this formula in order to make this template more user friendly.

    so here's the formula... if request date(B) is greater than today's date plus 5 work days, then enter that date
    if there's a stock date(AC) enter that date plus 5 days,
    if there's 1st order date (AG) enter that date plus 5 work days
    if theres a 2nd order date (AI) ""
    if theres a 3rd order date (AK) ""

    =IFERROR(IF(DATE(MID($B3,2,2)+100,MID($B3,4,2),RIGHT($B3,2))>WORKDAY(NOW(),5),DATE(MID($B3,2,2)+100,MID($B3,4,2),RIGHT($B3,2)),IF(AC3<>0,AC3+5,IF(AG3<>0,WORKDAY(DATE(MID($AG3,2,2)+100,MID($AG3,4,2),RIGHT($AG3,2)),5),IF(AI3<>0,WORKDAY(DATE(MID($AI3,2,2)+100,MID($AI3,4,2),RIGHT($AI3,2)),5),IF(AK3<>0,WORKDAY(DATE(MID($AK3,2,2)+100,MID($AK3,4,2),RIGHT($AK3,2)),5),""))))),"")

    thanks in advance for any help!
    Last edited by jlstidham; 08-14-2013 at 07:58 AM.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: VBA for long if formula

    In a race, VBA rarely beats using built-in Excel formulas. Looking at yours, I don't think VBA would make it any faster. The parsing of the odd date construct would have to happen regardless.

    Some suggestions:
    - Instead of MID(B3,2,2)+100, can you use LEFT(B3,3)?
    - You could calculate the B3 cell twice in your statement. Maybe a helper column that converts that text date to a real date would help. For example, if your helper column is C, then it shortens to something like this:
    =IFERROR(IF(C3>WORKDAY(NOW(),5), C3, IF(AC3...
    - I am surprised this is causing your computer to freeze. This really doesn't seem that taxing, but, of course, if you have thousands of these, then it will take a bit. I just used your formula on a test sheet with over 10K dates in your format and it was almost instantaneous.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

+ 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. Massive =IF together with =DATE formula
    By beseda2004 in forum Excel General
    Replies: 7
    Last Post: 02-08-2012, 07:43 AM
  2. Conditional Formatting Is Really Slowing Down My Computer, Any Suggestions?
    By Orangeworker in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-10-2010, 03:28 PM
  3. Pre-written formula
    By Newton1234 in forum Excel General
    Replies: 2
    Last Post: 06-05-2008, 04:51 AM
  4. make me less ugly please
    By dabith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2006, 02:45 AM
  5. Ugly Problem
    By Alan Graybosch in forum Excel General
    Replies: 1
    Last Post: 05-11-2006, 11:00 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