Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Simple custom function

I am trying to program a custom function to make some simple math simpler.
Unfortunately this is my first swing at a custom function or VBA for that
matter. I would like to be able to pass 6 variables to a function and have it
do the following math:

CrossP(A1, A2, A3, B1, B2, B3)
CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 * B2 - A2
- B1) ^ 2) ^ 0.5

Any thoughts?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Simple custom function

function CrossP(A1 as double, A2 as double, A3 as double, B1 as double, B2 as
double, B3 as double) as double
CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 * B2 - A2
- B1) ^ 2) ^ 0.5
End Function


"Ryan" wrote:

I am trying to program a custom function to make some simple math simpler.
Unfortunately this is my first swing at a custom function or VBA for that
matter. I would like to be able to pass 6 variables to a function and have it
do the following math:

CrossP(A1, A2, A3, B1, B2, B3)
CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 * B2 - A2
- B1) ^ 2) ^ 0.5

Any thoughts?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Simple custom function

I am still getting a #name error, this is exactly what I have in the VBA
editor;

Function CrossP(A1 As Double, A2 As Double, A3 As Double, B1 As Double, B2
As Double, B3 As Double) As Double

CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 * B2 -
A2 - B1) ^ 2) ^ 0.5

End Function

"Patrick Molloy" wrote:

function CrossP(A1 as double, A2 as double, A3 as double, B1 as double, B2 as
double, B3 as double) as double
CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 * B2 - A2
- B1) ^ 2) ^ 0.5
End Function


"Ryan" wrote:

I am trying to program a custom function to make some simple math simpler.
Unfortunately this is my first swing at a custom function or VBA for that
matter. I would like to be able to pass 6 variables to a function and have it
do the following math:

CrossP(A1, A2, A3, B1, B2, B3)
CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 * B2 - A2
- B1) ^ 2) ^ 0.5

Any thoughts?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Simple custom function

apologies ... I've been away. However, your code works fine for me.....



Option Explicit

Sub test()

Debug.Print CrossP(1, 2, 3, 4, 5, 6) ' 6.78232998312527

End Sub

Function CrossP(A1 As Double, A2 As Double, A3 As Double, B1 As Double, B2
As Double, B3 As Double) As Double

CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 * B2 -
A2 - B1) ^ 2) ^ 0.5

End Function


"Ryan" wrote in message
...
I am still getting a #name error, this is exactly what I have in the VBA
editor;

Function CrossP(A1 As Double, A2 As Double, A3 As Double, B1 As Double, B2
As Double, B3 As Double) As Double

CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 *
B2 -
A2 - B1) ^ 2) ^ 0.5

End Function

"Patrick Molloy" wrote:

function CrossP(A1 as double, A2 as double, A3 as double, B1 as double,
B2 as
double, B3 as double) as double
CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 * B2 -
A2
- B1) ^ 2) ^ 0.5
End Function


"Ryan" wrote:

I am trying to program a custom function to make some simple math
simpler.
Unfortunately this is my first swing at a custom function or VBA for
that
matter. I would like to be able to pass 6 variables to a function and
have it
do the following math:

CrossP(A1, A2, A3, B1, B2, B3)
CrossP = ((A2 * B3 - A3 * B2) ^ 2 + (A1 * B3 - A3 * B1) ^ 2 + (A1 *
B2 - A2
- B1) ^ 2) ^ 0.5

Any thoughts?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a custom function to interpret another custom engine func Ryan Excel Programming 0 March 3rd 08 07:18 PM
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Simple Custom Function??? Mike Excel Programming 1 August 17th 07 02:10 AM
Simple Custom Function??? Mike Excel Programming 0 August 17th 07 01:45 AM
How to create a simple VBA Custom Function Edmund Excel Programming 5 May 22nd 06 08:49 PM


All times are GMT +1. The time now is 09:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"