Results 1 to 5 of 5

Thread: making excel functions *resolved*

  1. #1

    Thread Starter
    Fanatic Member seec77's Avatar
    Join Date
    Jan 2003
    Posts
    596

    making excel functions *resolved*

    in excel vba, how can i make functions, so i can use the later like: "=Function()"...
    i tried doing a simple "Public Function" but it doesn't work... please help me!
    Last edited by seec77; Jun 14th, 2003 at 07:14 AM.
    Best Regards,
    seec77

    If you helped me, cosinder yourself thanked.

    Get each and every Garfield strip here!
    Here you can get all Calvin & Hobes strips!
    Damn UComics! It was probably unprofitable for them to allow us to just download Garfield and Calving & Hobes strips... so they made folder indexing unallowed on their server!!!

    I am 33% addicted to Counterstrike. What about you?
    I am 23% addicted to Star Wars. What about you?
    I am 0% addicted to Tupac. What about you?

  2. #2
    Lively Member
    Join Date
    Jun 2003
    Location
    france
    Posts
    71
    maybe i misunderstood, but if you want to put a fonction in a cell just type

    range("A1").value = "=your fonction"
    example with the now fonction
    Range("AI6:").Value = "=NOW()"
    your automatic editor can capture the fonction like this you don't have to type it

  3. #3
    Lively Member
    Join Date
    Jun 2003
    Location
    france
    Posts
    71
    ah and if you want to save it for later you can use a string like

    string = "=now()"
    and later
    range("A1").value = string

  4. #4
    Lively Member
    Join Date
    Apr 2003
    Location
    Georgetown, Texas
    Posts
    114

    Creating functions

    Here's one way:

    Start a macro by hitting Tools, Macro, Record New Macro. Enter the shortcut, . Then, stop it, by hitting Tools, Macro, Stop Recording.

    Now, hit View, Toolbars, Visual Basic
    On the Visual Basic toolbar, hit Visual Basic Editor, and double click on the module of the macro you just created. Below the last End Sub, paste your function code. Here is an example that works for me:

    =================================
    Function SumNum(MyCell As Range) As Integer

    ' This function adds the digits in a number.
    ' Its syntax is: =SumNum(B2), or any other cell reference

    Dim MyLen, i As Integer
    MyLen = Len(MyCell)
    For i = 1 To MyLen
    SumNum = SumNum + Mid(MyCell, i, 1)
    Next i
    End Function
    ================================

    The new function is now stored in the VB portion, and it is now available as any other function. As an example:

    Any place on your spreadsheet, enter: =SumNum(C23) If cell C23 has the number 2469 in it, then your function will show the sum of the digits 2+4+6+9, or 21.

  5. #5

    Thread Starter
    Fanatic Member seec77's Avatar
    Join Date
    Jan 2003
    Posts
    596
    thanks all!
    Best Regards,
    seec77

    If you helped me, cosinder yourself thanked.

    Get each and every Garfield strip here!
    Here you can get all Calvin & Hobes strips!
    Damn UComics! It was probably unprofitable for them to allow us to just download Garfield and Calving & Hobes strips... so they made folder indexing unallowed on their server!!!

    I am 33% addicted to Counterstrike. What about you?
    I am 23% addicted to Star Wars. What about you?
    I am 0% addicted to Tupac. What about you?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width