thank you Andre
it was really good and I can learn from it.
do you have any document that explain these kind of projects, for example using VB to pass data to GAMS?
For excel ( passing data from excel to GAMS) the file that Alireza sent was very good for me and I learn much about it.
bests
On Sun, Jul 31, 2011 at 1:33 AM, Savitsky Andre wrote:
HI!
Please create in EXCEL button and put inside script
Dim bb As String
Dim aa As String
Dim temp As String
Dim how_many As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Name As String
Dim Result(12) As Double
Dim Row_position(10) As Integer
Dim Path_output As String
Dim Path_output1 As String
Dim Path_output2 As String
Dim Path_output3 As String
Dim Path_output4 As String
Path_output = Worksheets(“Main”).TextBox2.Text
Path_output1 = Path_output & "" & “result_1.txt”
Path_output2 = Path_output & "" & “result_2.txt”
Path_output3 = Path_output & "" & “result_3.txt”
Path_output4 = Path_output & "" & “result_4.txt”
Row_position(1) = 10
Row_position(2) = 20
Row_position(3) = 30
Row_position(4) = 50
Row_position(5) = 110
Row_position(6) = 200
i = 1
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Volume”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = “at the end”
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "of month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “in MAF”
i = 2
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “End of the”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = “lake”
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “level (metr)”
i = 3
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Power”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "generation "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "in lake "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(Th mgvth)”
i = 4
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Canal diversion”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "at the canal "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "head "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”
i = 5
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Flow From "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " node N1 to "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " node N "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”
i = 6
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Spliting "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " water "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " (MAF) "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “”
For i = 1 To 6
j = Row_position(i)
If i 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmm
Next j
mmm:
Worksheets(“Results”).Cells(Row_position(1) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(1) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)
counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmm
Next j
mmmm:
Worksheets(“Results”).Cells(Row_position(2) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(2) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)
counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmmm
Next j
mmmmm:
Worksheets(“Results”).Cells(Row_position(3) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(3) + i, 2 + j) = Result(j)
Next j
Next i
aa = f.ReadLine
For j = 1 To 7
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 10) = bb
Worksheets(“Results”).Cells(1 + j, 11) = aa
Next j
For j = 1 To 4
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 12) = bb
Worksheets(“Results”).Cells(1 + j, 13) = aa
Next j
'========================================================================
f.Close
\
This script transport data from result1.txt to spreadsheet “result” in
EXCEL
How to make txt file in GAMS You can found in guide of GAMS
30.07.2011, 12:22, “Alireza Bahari” :
If you Like, i can hellp you. tell me abaou your project in ditail
alireza.b.1201@gmail.com
On Jul 23, 6:49 pm, Babak Saleck Pay wrote:
Dear all
pleas tell me what is the easiest way to transfer data between Excel and
GAMS (writing results from GAMS to Excel and reading data from Excel to
GAMS).
Pleas help me as I am in hurry for my project.
Thank you in advance.
–
Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
–
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
–
With kindly regards!
Andre
Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
–
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.