Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Data Validation/Lookup function does function correcty | Excel Worksheet Functions | |||
Re-entrant call to VBA | Excel Programming | |||
User Function Question: Collect Condition in Dialog Box - But How toInsert into Function Equation? | Excel Programming | |||
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) | Excel Worksheet Functions | |||
Excel - User Defined Function Error: This function takes no argume | Excel Programming |