close

Suppose I have a spreadsheet that performs a complicated calculation,
involving LOOKUP functions, and other structures that are not easily
expressed in a single-cell formula or macro.

I would like to treat the whole sheet as a formula, with one cell as
the input, and another as the output. Then on another sheet, I would
like to use that formula, possibly multiple times with different input
values each time (to generate charts or graphs with the variable input
values for example).

Is there any way to define a spreadsheet as a function in this manner?
If not, is there another way to approach this problem?

Thanks,

Tim.Tim,

You would need to use a macro to step through your input values, force a calculation, and store the
output.

For example, let's say that your input cell is Sheet1 A1, and your output cell is Sheet1 B10. On
Sheet2, you have a list of input values, starting in cell A2 and going down the column, and you want
the outputs in Sheet2 column B, on the same row - the macro below shows how to do it.

HTH,
Bernie
MS Excel MVP

Sub TryNow()
Dim myCell As Range
Dim myRange As Range

With Worksheets(quot;Sheet2quot;)
Set myRange = .Range(quot;A2quot;, .Cells(Rows.Count, 1).End(xlUp))
End With

For Each myCell In myRange
Worksheets(quot;Sheet1quot;).Range(quot;A1quot;).Value = myCell.Value
Application.CalculateFull
myCell(1, 2).Value = Worksheets(quot;Sheet1quot;).Range(quot;B10quot;).Value
Next myCell

End Subgt; wrote in message oups.com...
gt; Suppose I have a spreadsheet that performs a complicated calculation,
gt; involving LOOKUP functions, and other structures that are not easily
gt; expressed in a single-cell formula or macro.
gt;
gt; I would like to treat the whole sheet as a formula, with one cell as
gt; the input, and another as the output. Then on another sheet, I would
gt; like to use that formula, possibly multiple times with different input
gt; values each time (to generate charts or graphs with the variable input
gt; values for example).
gt;
gt; Is there any way to define a spreadsheet as a function in this manner?
gt; If not, is there another way to approach this problem?
gt;
gt; Thanks,
gt;
gt; Tim.
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()