English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm writing some macros in Visual Basic for Applications but I want to use simple excel functions such as STDEV on these rather than write new code to do the calculations...

I can't put the functions directly into the sheet because the sheet itself is generated by the VBA code and the exact location of the data varies depending on the source datasheet coming into the Macro.

Is there any way I can just call built-in Excel Functions directly in VBA?

Thanks in advance.

2006-11-18 04:54:19 · 3 answers · asked by the last ninja 6 in Computers & Internet Programming & Design

3 answers

If you are talknig about the VBA of Excel, then
Yes
There is a way
I answered this one 2 days ago

It is by using the object "WorksheetFunction"
Type
Worksheetfunction.
in your code and, you will see the list of available functions that you can use from VBA in XL.
This list will not have some big functions like OFFSET, or ADDRESS
any way
About the other solution (Putting function in your worksheet), actually, you can do the function in another worksheet and link the result to the one that you need.
This technique is better, just to allow your user to see what function you used for this result

Mail me if you need more info

Enjoy my profile, I am the VBAXLMan

2006-11-19 20:43:41 · answer #1 · answered by Anonymous · 2 0

I don't know of a way to use the Excel functions in VBA, but you could use VBA to add the functions to specific cells when it creates the worksheet. You'd have to come up with a way to determine where the data is though, since you said it varies. Example: Sub test() Cells(1, 1) = 30 Cells(1, 2).Formula = "=sin(" & Cells(1, 1) & ")" End Sub - Rich

2016-05-22 01:01:29 · answer #2 · answered by Anonymous · 0 0

I don't know of a way to use the Excel functions in VBA, but you could use VBA to add the functions to specific cells when it creates the worksheet. You'd have to come up with a way to determine where the data is though, since you said it varies.

Example:
Sub test()
Cells(1, 1) = 30
Cells(1, 2).Formula = "=sin(" & Cells(1, 1) & ")"
End Sub

- Rich

2006-11-18 05:58:49 · answer #3 · answered by Rich 2 · 0 0

fedest.com, questions and answers