Vector Cross Product is not available in Excel, what do I do?

7.9k Views Asked by At

This is extremely frustrating.

I can use Excel to do some complex linear algebra, but I can't use it to find a cross product between two vectors.

I read online that they purposely omitted this functionality,

Furthermore, I can't seem to be able to find any VBA scripts that I can add in as a module that will do this for me.

There is only 1 page I found that has vector scripts, https://newtonexcelbach.wordpress.com/2011/08/21/dots-and-crosses/

But when I add this module, I get all 0s when doing any of the Cross() functions on two vectors

And the example spreadsheet actually turns into errors when editing is enabled.

Can anybody help me with a resource on how I can add vector cross products to Excel?

I have a lot of points and I would prefer not to use an external cross product calculator to do this simple function that has been available in calculators since 1980's

Thanks, -D

1

There are 1 best solutions below

1
On

Ok, I found one that actually works, but it only does horizontal vectors, does anyone know how to change this to work on vertical vectors?

https://www.excelbanter.com/excel-worksheet-functions/209233-how-do-you-use-visual-basic-find-cross-product-two-vectors.html

--------------------
Function vCP(v1 As Variant, v2 As Variant) As Variant
vCP = Array(v1(2) * v2(3) - v1(3) * v2(2), _
v1(3) * v2(1) - v1(1) * v2(3), _
v1(1) * v2(2) - v1(2) * v2(1))
End Function
--------------------

I know this is now a more of a programming question. Should this be moved to stackoverflow? Is there a way to do this?

EDIT:

To use this code, press Alt+F11 in excel

Select some VBA project on the right that is always open

Then insert->module

Paste the code below without the dashed lines, save

Select 3 horizontal cells in a row,

Type something like =vCP(R7:T7,N7:P7)

Hit CTRL+SHIFT+ENTER