Thread: Range naming
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bill Manville Bill Manville is offline
external usenet poster
 
Posts: 473
Default Range naming

BigJim wrote:
I want to apply a user-defined function to populate the
results array (one column at a time) from the Scores
array.


A user-defined function can only alter cells by returning a value into
the cell(s) from which it was called.

So you could, for example, have a function that returns an array of
values to the destination range and array-enter the function call into
that range using Ctrl+Shift+Enter.

The function might look like:

Function CalcPercentage(rSource As Range)
Dim rResults()
Dim iRow As Integer
ReDim rResults(1 To rSource.Rows.Count, 1 To 1)
For iRow = 1 To rSource.Rows.Count
rResults(iRow, 1) = something or other
Next
CalcPercentage = rResults
End Function

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup