+ Reply to Thread
Results 1 to 16 of 16

Creation of a UDF function for excel

  1. #1
    Registered User
    Join Date
    11-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Creation of a UDF function for excel

    I'm quite new to this.

    I'm trying to create a formulae that does this.

    =mul(3)

    then it will automatic display 3 in the cell and -6 in the column directly below.

    please help
    Last edited by arlu1201; 11-26-2012 at 08:03 AM. Reason: Thread title

  2. #2
    Registered User
    Join Date
    11-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: create formulae that does this simple

    I've done this, but it's not working.

    Please Login or Register  to view this content.
    Last edited by arlu1201; 11-26-2012 at 06:21 AM. Reason: Add code tags in future.

  3. #3
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: create formulae that does this simple

    NO formula can affect a cell other than the one it is in, so what you really need is a conditional formula that checks the cell above it to see if it contains 3, then it displays 6, also.....umm...whats mul(3)...i cannot find that function...
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  4. #4
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: create formulae that does this simple

    Aaah...an UDF...the rules still apply, will only return a value, cannot change another cell..make it a Proc and it MIGHT work...

    -Edit-
    Also, A procedure will not return a value
    Last edited by dredwolf; 11-26-2012 at 04:42 AM.

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: create formulae that does this simple

    Why not 3 in A1 cell and and in A2 =(A1*-2)?

    Please explain your requirement clearly for our better understanding.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  6. #6
    Registered User
    Join Date
    11-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: create formulae that does this simple

    Because I need a row of numbers A3,A4,A5... whereby A3 = A2*(-0.5), A4=A3*2.1, so on

    So I figure if I can just do =mul(3), it will work out what I need.
    and since it repeats fairly often I will save a lot of time.

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: create formulae that does this simple

    In which basis the counter (-0.5) and 2.1 is increasing? could you please explain the logic?

  8. #8
    Registered User
    Join Date
    11-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: create formulae that does this simple

    basically =mul(5)

    i want to yield the result, and since it is recurring a lot in my spreadsheet, i can do mul(3), mul(4),

    5
    (10)
    5
    10

  9. #9
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: create formulae that does this simple

    Thanks for the reply please continue the next subsequent series....

  10. #10
    Registered User
    Join Date
    11-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: create formulae that does this simple

    I just need help to create this one UDF. The next subsequent series is not required.

  11. #11
    Registered User
    Join Date
    11-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Creation of a UDF function for excel

    Can anyone help in this?

    Essentially, I like the use a formulae like =mul(5) to get the result

    5
    (10)
    5

    or mul(-3) to get
    (3)
    6
    (3)

    Since it is recurring, it will help me save a lot of time.

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,907

    Re: Creation of a UDF function for excel

    I, too, do not understand your reasoning for putting this into a UDF, but I won't try to dissuade you. A few things I've learned:

    1) A UDF can return multiple values if it is programmed as an array function. One of the first things you will need to learn is how to enter array functions into Excel. I would suggest a search of the Excel help files for "entering array formulas" and the help files for array functions like the transpose(), minverse(), linest() functions. If you are unfamiliar with array functions, this should help you understand the mechanics (ctrl+shift+enter vs enter) of entering an array function.
    2) I have never had success declaring a function as an array function. I've had good success declaring the function as a variant type, dimensioning an array to temporarily store the result while the function is running, then assigning the function to return that array. This looks something like this:
    Please Login or Register  to view this content.

  13. #13
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Creation of a UDF function for excel

    Putting in my 2¢,
    As someone mentioned earlier, a UDF (or any other Excel Equation) can only affect the cell it is in. You need to use an event triggered macro to affect values in other cells. If I could figure out your logic, this would be fairly simple but I'm having trouble. An example worksheet might help a lot here, showing several examples (go advanced> Manage attachments).

    you state
    Because I need a row of numbers A3,A4,A5..
    do you need a column of numbers or a row of numbers? A2,A3, A4 is a column. I was thinking that you always wanted to multiply by a specific number down the column but in your example, you use -0.5, then 2.1.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  14. #14
    Registered User
    Join Date
    11-26-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Creation of a UDF function for excel

    It's basically =mul(5)that is entered into a cell or a block of 3 cells to produce the output.

    cell A1 5
    cell A2 (10)
    cell A3 5


    Maybe it is not possible.

  15. #15
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Creation of a UDF function for excel

    Why is A3 = 5? Shouldn't it be -2* A2 or 20? I think this would be possible once I figure out the logic.

  16. #16
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Creation of a UDF function for excel

    May be this...

    Assuming Cell A1 is your input cell

    A1 cell
    5

    In A2 cell
    =IF(ROW()=2,$A$1*(-2),$A$1)
    Drag it to A3 also.

    I have posted this yesterday itself but some of my posts are disappearing I don't know the reason...

+ 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