|
-
Jun 13th, 2003, 07:35 AM
#1
Thread Starter
Fanatic Member
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?
-
Jun 13th, 2003, 09:45 PM
#2
Lively Member
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
-
Jun 13th, 2003, 09:47 PM
#3
Lively Member
ah and if you want to save it for later you can use a string like
string = "=now()"
and later
range("A1").value = string
-
Jun 14th, 2003, 12:57 AM
#4
Lively Member
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.
-
Jun 14th, 2003, 07:07 AM
#5
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|