【发布时间】:2012-02-13 21:00:33
【问题描述】:
我正在构建一个当前看起来像这样的模型 - 输入表 --> 基本 excel 函数 --> 输出表。基本的东西对吧?!
我想通过添加 VBA 生成的输出(新工作表)使模型更加动态,仅根据以下内容提取满足特定条件的数据:
Sub GenerateTargets()
'Dim UpperRange As Double
'Dim LowerRange As Double
'Dim Percentile As Double
'Dim Test
'Dim Total Revenue {Note: [This is a header in the output sheet] [should I use Array or Range? If array is it Stat or Dynamic] I might change the input later on and increase the number of observations}
'Read Values in Cells
UpperRange = Worksheets("sheet2").Cells(x, y).Value
LowerRange = Worksheets("sheet2").Cells(x, y).Value
Test = UpperRange > Percentile > LowerRange
Case Test Is True
[This is the test I want to generate]
Case Test Is False
[I do not want this to show in my new sheet]
[Here I would like to add another Case to stop counting if [Total revenue = ##]
End Sub
如何要求它在输出中生成相同的标头/数据但消除错误情况,同时在达到某个阈值时停止计数。
不胜感激任何帮助/建议 --
【问题讨论】:
-
请提供有关输入和输出表的更多信息(提供和示例)。