purple_egg
New Member
- Joined
- Mar 9, 2015
- Messages
- 5
I am currently working on VRP with "D arrays. I worked through initial solution, and now I did random descent technique. However, I am supposed to store the results from the previous runs that I did in the seperater worksheet in excel- a log has to be kept. There is a problem with my code, as the solutions do not show up in the second wosksheet and are not stored at all. Could someone have a look at my code and spot any mistake. I am sure it missing some commands, and IU don't know how to deal with it to get it right.
' log sub that try to keep results after every run DOES NOT WORK
Sub log(inputfilename As String)
Dim i As Long, n As Long
n = 100000
Sheets("Sheet2").Select
Sheets("Sheet2").Activate
Cells(1, 1).Value = "problem name"
Cells(1, 2).Value = "Initial Cost"
Cells(1, 3).Value = "Best Cost"
For i = 1 To n / 10000
Sheets("sheet2").Cells(i + 1, 1).Value = inputfilename
Sheets("sheet2").Cells(i + 1, 2).Value = Sheets("sheet1").Cells(1, 2).Value
Sheets("sheet2").Cells(i + 1, 3).Value = Sheets("sheet1").Cells(2, 2).Value
i = i + 1
Next i
End Sub
' log sub that try to keep results after every run DOES NOT WORK
Sub log(inputfilename As String)
Dim i As Long, n As Long
n = 100000
Sheets("Sheet2").Select
Sheets("Sheet2").Activate
Cells(1, 1).Value = "problem name"
Cells(1, 2).Value = "Initial Cost"
Cells(1, 3).Value = "Best Cost"
For i = 1 To n / 10000
Sheets("sheet2").Cells(i + 1, 1).Value = inputfilename
Sheets("sheet2").Cells(i + 1, 2).Value = Sheets("sheet1").Cells(1, 2).Value
Sheets("sheet2").Cells(i + 1, 3).Value = Sheets("sheet1").Cells(2, 2).Value
i = i + 1
Next i
End Sub