+ Reply to Thread
Results 1 to 4 of 4

Convert a worksheet formula to a function

Hybrid View

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Convert a worksheet formula to a function

    In order to rationalise a weekly average to take account that one unit may not be considered a full unit for division purposes (ie if a units revenue is 50% of target revenue chances are that unit can only be considered a 1/2 unit, if two or more are in the same area then instead of considering the total revenue divided by total number of units, we are going to have to consider those half units)

    These can be done manually by assigning a number to a column ie: 1,0.75,0.5.0.25,0 and summing the total over the total number of units

    the following rough formula is accurate in recreating the result automatically so saving time

    The problem lies with the "content" of the formula as the figures used would subject to more scrutiny than the resultant outcome which is fit for its purpose

    Can I change this formula
    =IF(OFFSET(F4,0,1)"is less than"3000,ROUNDUP((G4/3000),1),1)
    in f4 to a function and replace formula (in f4) with "=function1"

    Any help appreciated
    Attached Files Attached Files
    Last edited by nigelog; 02-20-2018 at 12:39 PM.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Convert a worksheet formula to a function

    I'm not sure if I understand your need completely.

    But can't you use named range to hold the formula and use the named range in cell to return value?

    Edit: Attached sample file.
    Attached Files Attached Files
    Last edited by CK76; 02-20-2018 at 11:44 AM.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Convert a worksheet formula to a function

    Hi, thanks Ck78
    I could and it would be a perfect solution

    Functions have been the solution to a few problems I've been given answers to on this site and I am trying to get a grasp on understanding them, hence this direction


    Ive tried
    Function Unit(revenue)
       If revenue < 3000 Then
         Unit = Application.Round(revenue / 3000, 1)
        
       Else
         Unit = 1
       End If
    
    
    End Function
    and
    =unit(g3)
    in cell f3 but cant get the result to round
    Last edited by nigelog; 02-20-2018 at 12:35 PM.

  4. #4
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Convert a worksheet formula to a function

    Sheet was not refreshing perfect when copied and pasted, Ill mark as solved

    Tidied up to

    Function Unit(revenue)
    Const myTarget As Integer = 3000
    
        If revenue < myTarget Then
            Unit = Application.Round(revenue / myTarget, 1)
        Else
            Unit = 1
        End If
    
    End Function
    Last edited by nigelog; 02-20-2018 at 12:58 PM.

+ 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] Convert Worksheet Function to VBA Function
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2017, 11:44 AM
  2. Help - Convert formula into function
    By sanju2323 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-19-2016, 10:48 PM
  3. Use IF function to convert units within the same worksheet
    By melvin88 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-19-2014, 06:33 AM
  4. Convert Worksheet Function to Macro?
    By BadDogTitan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2013, 11:09 PM
  5. CONVERT worksheet formula into vba code
    By tony0710 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-21-2013, 02:44 AM
  6. Convert Array formula to VBA to speed up worksheet
    By MarathonMan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2007, 06:17 PM
  7. Convert cell data into a worksheet name via a formula
    By Sandy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2005, 02:06 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