LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Re-entrant function

Several weeks ago I posted a version of this and I thought I had it solved
with help from this DG - but not so!

xx(j,k) calculates the crossproduct of two 3-dimensional vectors. the
result is returned in either a row or column on the work sheet as selected by
the user. Normally the function works ok. It even works ok in
"=xx(xx(i,j),xx(k,l)) when the selection is a row but crashes at line 9, on
the third pass (Va and Vb are then Variants) when the selection is a column.
I'm using Option Base 1.

Function XX(Va, Vb)
Debug.Print TypeName(Va), TypeName(Vb)
Static r As Integer, c As Integer

r = Selection.Rows.Count
c = Selection.Columns.Count

Dim CP() As Double
If r c Then
ReDim CP(3, 1)
8 MsgBox "Got to line 8 OK"
9 CP(1, 1) = Va(2) * Vb(3) - Va(3) * Vb(2)
10 MsgBox "Got to line 10 OK"
CP(2, 1) = Va(3) * Vb(1) - Va(1) * Vb(3)
CP(3, 1) = Va(1) * Vb(2) - Va(2) * Vb(1)
Debug.Print r, CP(1, 1), CP(2, 1), CP(3, 1)
Else
ReDim CP(1, 3)
11 CP(1, 1) = Va(2) * Vb(3) - Va(3) * Vb(2)
CP(1, 2) = Va(3) * Vb(1) - Va(1) * Vb(3)
CP(1, 3) = Va(1) * Vb(2) - Va(2) * Vb(1)
Debug.Print r, CP(1, 1), CP(1, 2), CP(1, 3)
End If
XX = CP
End Function

Can anyone help?

--
Thanks for your help
 
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
Excel Data Validation/Lookup function does function correcty Kirkey Excel Worksheet Functions 2 May 25th 09 09:22 PM
Re-entrant call to VBA LesHurley Excel Programming 3 February 4th 08 09:57 PM
User Function Question: Collect Condition in Dialog Box - But How toInsert into Function Equation? SteveM Excel Programming 1 January 3rd 08 03:45 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM


All times are GMT +1. The time now is 07:02 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"