Amend existing code with a loop a copy & paste

mfer

New Member
Joined
Feb 7, 2013
Messages
13
Hello –



I am hoping someone can help provide some additional code.



This original code (not mine, and I wish I could find the original author to cite them) allows for an automatic goal seek through a number of scenarios. It works fine as-is.



What I’d like it to do is after each scenario, as it is cycling through and solves for the goal seek is to then copy a value from a difference cell (that was a calculated cell based on the value determined from the goal seek) and then paste it in a particular cell. After each scenario, paste it into the next row. I run thousands of scenarios at one time, so this would be helpful. (Note, I had a way of doing this with Data Tables too, but it is just too resource intensive for my computer to handle efficiently).



Original Code without the change:



Sub blah1()

For Each cll In Range("Y39")

For Each celle In Range("ScenarioRange")

Range("F31").Value = celle.Value

Range("N36").Value = cll.Value

Range("O9").GoalSeek Goal:=Range("P36"), ChangingCell:=Range("F31")

Cells(celle.Row, cll.Column).Value = Range("F31")

Next celle

Next cll

End Sub





Want to add this functionality:


Scenario 1, [copy the value from cell AO39 to AO40

Scenario 2, [copy the value from cell AO39 to AO41

Scenario 2, [copy the value from AO39 to AO42]

Etc





Note: “ScenarioRange” is just a defined name of cells. Like I say, it works fine. =OFFSET('MAIN TOGGLE'!$M$39,1,0,'MAIN TOGGLE'!$M$36)



Any help would be appreciated!





Tks

M
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,215,694
Messages
6,126,250
Members
449,305
Latest member
Dalyb2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top