+ Reply to Thread
Results 1 to 3 of 3

Translate Formula to VBA Code

  1. #1
    Forum Contributor
    Join Date
    07-15-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    129

    Translate Formula to VBA Code

    Hi guys,

    I'm trying to create a VBA loop that does a few things--mainly to restart every 5 calendar days--, but to start out I just need the basic formula to be translated into a VBA formula.

    Here's the formula
    =(IF(SUM($AX4:$BH4)>=45,SUM(SUMIF($AX$4:$BH$4,LARGE($AX$4:$BH$4,{1,2,3}),$BV4:$CF4))+SUM(SUMIF($AX$4:$BH$4,SMALL($AX$4:$BH$4,{1,2,3}),$BV4:$CF4)),FALSE))

    Explained: As it is now, column CH has a formula that takes the sum of the top three and bottom three values in columns BV:CG. The criteria for "top" and "bottom" is based on the ranks in AX:BH--i.e. if a cell's corresponding "rank" is in the top three highest or lowest in all of the ranks of that row, then that cell is added to the sums in CH. However, the same criteria (i.e. the same ranks in AX:BH) applies to five rows in the range BV:CG *The formula also only runs if the sums of all corresponding ranks on that row add up to 45*
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-02-2009
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Translate Formula to VBA Code

    What do you mean exactly by "VBA formula"? If you mean can the formula in your post be inserted into a workbook by VBA then yes: you just use
    Please Login or Register  to view this content.
    (Replacing "YourSheetName" with the name of the target sheet tab, and replacing "A1" with whatever target cell you want the formula to go in.)

    Apologies if I've misunderstood your question.

  3. #3
    Forum Contributor
    Join Date
    07-15-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    129

    Re: Translate Formula to VBA Code

    Sorry, I know very little about VBA so I probably didn't word my question clearly.

    What I want is a VBA code that does what the excel formula does, but step by step. My end goals are to:
    First: Instead of using different ranks each day, I need to use the same criteria for the whole work week (5days). In other words, I need to target these parts of the above formula "SUMIF($AX4:$BH4,LARGE($AX4:$BH4,{1,2,3}),$BV4:$CF4)" and "SUMIF($AX4:$BH4,SMALL($AX4:$BH4,{1,2,3}),$BV4:$CF4)" and change them so that the large{1,2,3} and small {1,2,3} of $AX4:$BH4 hold for BV4:CF8, i.e. the whole week.
    Second: The criteria on the last day of the proceeding loop is the criteria for the first day of the next loop. In other words, thought about in a real life scenario, one can only make a decision for that week based on the criteria of the day before.
    Third: If the loop hits a "FALSE" statement (which would happen if the sum of the ranks is less than 45), I need excel to take the next available criteria, and apply that to the next 5 days.
    Fourth: This (above statement) means that the loop needs to be linked to a calender. I can't just apply the same criteria to 5 cells, the next criteria to the next 5 cells, ect, because on the FALSE days, there would not be a sum, but instead the sum would pick back up at the next available criteria, and THEN apply that to the next 5 cells.

    In order to even start on that stuff, I need to have a VBA code that I can manipulate. Does that make sense?

+ 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. Translate multi language file to english using VBA code
    By Kiran Kurapati in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-11-2013, 06:59 AM
  2. Translate VB.net code into VBA
    By karo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2012, 01:50 PM
  3. [SOLVED] Could someone HELP TRANSLATE this simple psuedo code into MACRO pl
    By bxc2739 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2006, 02:46 PM
  4. Replies: 4
    Last Post: 04-27-2006, 02:09 PM
  5. translate ws formula to vba code
    By L Scholes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2006, 10:40 PM

Tags for this Thread

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