View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming,comp.apps.spreadsheets,microsoft.public.excel.misc
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Macro Questions: Returning multiple results, description of parameter syntax et al.

1) Nothing useful found in Excel online help for "Function" and all
its sub-categories

Information I gave was copied from the help file - not sure what you are
looking at. Option argument is well explained in the help and I gave you
the help example as well.

2) How can one return multiple results from a Macro?

Public function MyFunction( arg as Range) as Variant
Dim results()
Redim results( 1 to arg.rows.count, 1 to arg.columns.count)
for i = 1 to arg.rows.count
for j = 1 to arg.columns.count
Results(i,j) = i*j
next
next
MyFunction = Results

Sub Tester1()
dim i as long, j as long, sStr as string, mvarr as variant
mvarr = MyFunction(Range("A1:B12")
for i = lbound(mvarr,1) to ubound(mvarr,1)
for j = ubound(mvarr,2) to ubound(mvarr,2)
sStr = sStr & mvarr(i,j) & ", "
next
debug.print sStr
sStr = ""
Next
End Sub


3) Why does Application.Sqrt( @) not work, whereas Application.Power(
@, 0.5) does?

All worksheet functions are not available in VBA, especially those that are
duplicated in VBA, such as sqrt

? sqr(500)
22.3606797749979

? 500^0.5
22.3606797749979

^ is an operator, there is no power function in VBA.



4) How would one specify multiple area ranges in an argument, and what
are these used for?

Range("A1,B9,G11:G31,N34:N56")

? Range("A1,B9,G11:G31,N34:N56").Address
$A$1,$B$9,$G$11:$G$31,$N$34:$N$56
? Range("A1,B9,G11:G31,N34:N56").Areas.Count
4

5) How can one measure computational effort, in terms of floating
point operations and computation time?

See Charles Williams site:
http://www.decisionmodels.com

6) I will return to "Cell formula or macro to write result of one cell
to another cell"

A formula can only return values to the cell in which it is located. It
can't assign a value to another cell.

I don't really understand your example, but you should be able to use simple
cell addresses to reference other cells.



--
Regards,
Tom Ogilvy