Hello,
After spending too much time on this problem, I am hoping to find some help here - seems like the right place. This is the last bit of code out of a larger macro - which (except for this bit) works fine.
I have one dynamically changing column - i.e. a column within which Solver loops through 19 rows and solves a bond math problem. That works fine. The trouble comes when I then try to copy/paste the results elsewhere. Each optimization I run is stand-alone; therefore, each set of results needs to be copied over to its own new column. Right now my code copies over only the LAST set of results to all the new columns sequentially - instead of copying each set of results to its own new column. Please see below:
Dim j As Integer
Dim x As Range
Set x = Range(Sheets("SuperBell").Cells(34, 15), Sheets("SuperBell").Cells(52, 15))
Dim i As Integer
For i = 34 To 52
SolverReset
SolverOk SetCell:="$Q$" & i, MaxMinVal:=3, ValueOf:="1", ByChange:="$O$" & i
SolverSolve (True)
Next i
x.Copy
Dim y As Range
For j = 19 To 21
Set y = Range(Sheets("SuperBell").Cells(10, j), Sheets("SuperBell").Cells(28, j))
y.PasteSpecial Paste:=xlPasteValues
Next j
Now, my j needs to ultimately loop 300 times, rather than 3, but you get the idea. I have the feeling I am making a very basic mistake somewhere, but at this point - beats me! I also browsed this forum for a while, but could not quite get at what I needed... So any and all help would be GREATLY appreciated. Thanks in advance!!
Best Regards,
-Nick N.
After spending too much time on this problem, I am hoping to find some help here - seems like the right place. This is the last bit of code out of a larger macro - which (except for this bit) works fine.
I have one dynamically changing column - i.e. a column within which Solver loops through 19 rows and solves a bond math problem. That works fine. The trouble comes when I then try to copy/paste the results elsewhere. Each optimization I run is stand-alone; therefore, each set of results needs to be copied over to its own new column. Right now my code copies over only the LAST set of results to all the new columns sequentially - instead of copying each set of results to its own new column. Please see below:
Dim j As Integer
Dim x As Range
Set x = Range(Sheets("SuperBell").Cells(34, 15), Sheets("SuperBell").Cells(52, 15))
Dim i As Integer
For i = 34 To 52
SolverReset
SolverOk SetCell:="$Q$" & i, MaxMinVal:=3, ValueOf:="1", ByChange:="$O$" & i
SolverSolve (True)
Next i
x.Copy
Dim y As Range
For j = 19 To 21
Set y = Range(Sheets("SuperBell").Cells(10, j), Sheets("SuperBell").Cells(28, j))
y.PasteSpecial Paste:=xlPasteValues
Next j
Now, my j needs to ultimately loop 300 times, rather than 3, but you get the idea. I have the feeling I am making a very basic mistake somewhere, but at this point - beats me! I also browsed this forum for a while, but could not quite get at what I needed... So any and all help would be GREATLY appreciated. Thanks in advance!!
Best Regards,
-Nick N.