Question
Can anyone debug this excel VBA? I am trying to copy 25 values from each sheet (A,B,C,D,E) to the sheet Optimization with single load and
Can anyone debug this excel VBA?
I am trying to copy 25 values from each sheet (A,B,C,D,E) to the sheet "Optimization with single load" and run the solver. Finally, I want to keep the result for each round of the solver in "sheet2".
Sub copytest() ' ' copytest Macro ' Dim A As Integer Dim B As Integer Dim C As Integer Dim D As Integer Dim E As Integer
For A = 0 To 9
Sheets("A").Select Range("D" & "(A*25)+1", "D" & "(25*A)+25").Select Application.CutCopyMode = False Selection.Copy Sheets("Optimization with single load").Select Range("F3:F27").Select ActiveSheet.Paste Next Index For B = 0 To 3 Sheets("B").Select Range("D" & "(B*25)+1", "D" & "(25*B)+25").Select Selection.Copy Sheets("Optimization with single load").Select Range("F28:F52").Select ActiveSheet.Paste For C = 0 To 7 Sheets("C").Select Range("D" & "(C*25)+1", "D" & "(25*C)+25").Select Selection.Copy Sheets("Optimization with single load").Select Range("F53:F77").Select ActiveSheet.Paste For D = 0 To 3 Sheets("D").Select Range("D" & "(D*25)+1", "D" & "(25*D)+25").Select Selection.Copy Sheets("Optimization with single load").Select Range("F78:F102").Select ActiveSheet.Paste For E = 0 To 5 Sheets("E").Select Range("D" & "(E*25)+1", "D" & "(25*B)+25").Select Selection.Copy Sheets("Optimization with single load").Select Range("F103:F126").Select ActiveSheet.Paste Range("AK25").Select SolverOk SetCell:="$AK$25", MaxMinVal:=2, ValueOf:=0, ByChange:="$AC$4:$AG$28" _ , Engine:=2, EngineDesc:="Simplex LP" SolverOk SetCell:="$AK$25", MaxMinVal:=2, ValueOf:=0, ByChange:="$AC$4:$AG$28" _ , Engine:=2, EngineDesc:="Simplex LP" SolverSolve Selection.Copy Sheets("Sheet2").Select Range("B2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False ActiveWorkbook.Save
Next E Next D Next C Next B Next A
End Sub
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started