调用目标查找子的场景分析宏

问题描述

我有一个场景分析宏,它计算 4 个不同场景的 NPV(每个场景都有独特的参数),其中 IRR 等于一个目标:

Sub ScenarioTable()

'Declare variables.
Dim i As Integer

'Dim InitialScenario As Integer
Dim ScenarioCount As Range
Dim rngScenariocopy As Range
Dim rngScenarioPaste As Range

'Populate variables with data from sheet.
Set InitialScenario = Range("Scenario_Switch")

'Set range variables to anchor cells on the worksheet.
Set ScenarioCount = Range("Scenario_Count")
Set rngScenariocopy = Range("Scenario_copy")
Set rngScenarioPaste = Range("Scenario_Paste")

'Start the counter at 1
i = 0

'Starting at an anchor point for each scenario number we test whether the cell is empty before continuing.
do while ScenarioCount.Offset(1,0).Errors.Item(1).Value = False
Set rngScenariocopy = Range("Scenario_copy")

'Paste output into column.
rngScenarioPaste.Offset(0,i).Value = rngScenariocopy.Value

'Call goalseek macro
Call GoalSeek.KDGoalSeek

'Input scenario number into the scenario manager.
InitialScenario.Value = i + 2
i = i + 1

Loop

'Return scenario back to original number.
InitialScenario.Value = 1

End Sub

代码输出确实为每种情况产生了 NPV,但每种情况下的 IRR 并不等于目标

我使用的目标搜索宏是:

Sub KDGoalSeek()
' Goal seeks a value using named ranges.
Application.ScreenUpdating = False


' Keyboard Shortcut: Ctrl+g

'Goal:=Range("Target") is the cell reflecting our goal value
'ChangingCell:=Range("GS_Input")the input cell that needs to adjust its value to achieve the goal
'Range("GS_Output"). is the cell that determines the changing cell i.e. the input
Range("GS_Output").GoalSeek Goal:=Range("Target"),ChangingCell:=Range("GS_Input")

Application.ScreenUpdating = True

End Sub

目标查找宏本身就是输出正确的目标 IRR,但在场景分析宏中使用时却没有。

感谢关于为什么场景分析宏没有输出目标 IRR 和相关 NPV 的帮助

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)