View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
SterlingA[_3_] SterlingA[_3_] is offline
external usenet poster
 
Posts: 1
Default Create scenarios using macro and data in cells


Thanks for the help. Using what you gave me this was what I finished
with. So I have a block of input, first column holds scenario name,
second column has data for the first variable, and third column the
data for third variable. You start the macro with the cursor in the
first row on the first scenario name. Macro captures the scenario name,
then the values using ActiveCell.Offset. I have a lot of hidden columns
so that is why the 5 and 10 for offsets. The Do loop keeps the macro
going until it hits an empty cell signifying the end of the scenarios.

pasted the code in case anyone else could use it after modifying to
their own needs.

Thanks again for the help.

Sub CreateScenario()
Dim line&, thename$, thevalues

Do
thename = ActiveCell.Value
thevalues = Array(CStr(ActiveCell.Offset(0, 5).Value),
CStr(ActiveCell.Offset(0, 10).Value))

ActiveSheet.Scenarios.Add Name:=thename, _
ChangingCells:=Range("D77,D39"), _
Values:=thevalues, _
Locked:=False, Hidden:=False
ActiveCell.Offset(1, 0).Select

Loop Until IsEmpty(ActiveCell)
End Sub


--
SterlingA
------------------------------------------------------------------------
SterlingA's Profile: http://www.excelforum.com/member.php...o&userid=10913
View this thread: http://www.excelforum.com/showthread...hreadid=382252