trunkmonkey
New Member
- Joined
- Jul 7, 2011
- Messages
- 2
Hello,
I am trying to increment in a macro, for a period set in a for loop. I need the macro to retrieve data from one sheet and paste it in another use solver and past the results in the original sheet. The code that I have so far is as follows:
Sub take4()
'
' take4 Macro
'
'
Sheets("switchgrass results").Select
For x = 115 To 162
Range("A115:C115").Select
Selection.Copy
ActiveCell.Offset(1, 0).Select
Sheets("Switchgrass model").Select
Range("R88:T88").Select
ActiveSheet.Paste
SolverOk SetCell:="$AB$96", MaxMinVal:=2, ValueOf:=0, ByChange:= _
"$B$126:$AA$126", Engine:=2, EngineDesc:="Simplex LP"
SolverSolve
ActiveWindow.ScrollColumn = 24
Range("AF96:AH96").Select
Selection.Copy
Sheets("switchgrass results").Select
Range("D115:F115").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveCell.Offset(1, 0).Select
Sheets("Switchgrass model").Select
Next x
End Sub
Any help would be greatly appreciated
Thanks!
P.S. if you suggest that I don't use a for loop and just have it run until an empty cell, I can do that as well.
I am trying to increment in a macro, for a period set in a for loop. I need the macro to retrieve data from one sheet and paste it in another use solver and past the results in the original sheet. The code that I have so far is as follows:
Sub take4()
'
' take4 Macro
'
'
Sheets("switchgrass results").Select
For x = 115 To 162
Range("A115:C115").Select
Selection.Copy
ActiveCell.Offset(1, 0).Select
Sheets("Switchgrass model").Select
Range("R88:T88").Select
ActiveSheet.Paste
SolverOk SetCell:="$AB$96", MaxMinVal:=2, ValueOf:=0, ByChange:= _
"$B$126:$AA$126", Engine:=2, EngineDesc:="Simplex LP"
SolverSolve
ActiveWindow.ScrollColumn = 24
Range("AF96:AH96").Select
Selection.Copy
Sheets("switchgrass results").Select
Range("D115:F115").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveCell.Offset(1, 0).Select
Sheets("Switchgrass model").Select
Next x
End Sub
Any help would be greatly appreciated
Thanks!
P.S. if you suggest that I don't use a for loop and just have it run until an empty cell, I can do that as well.