Hi all expert there,
I'm new to this website and so with the macro thing. Recently, I learn on how to use macro in simulating reservoir for hydropower project. I have managed to prepared one but it too time consuming. Can someone out there to check if there is any improvement for my vba below? Your comment is highly appreciated.
Sub Button1_Click()
Dim y, x As Integer
x = Cells(18, 2).Value + 20
For y = 21 To x
' First run plant discharge starts at 0.
Cells(y, 8).Value = 0
Do While Cells(y, 6).Value >= Cells(7, 5).Value ' Current reservoir level above MOL
' Increment @ 5.
Cells(y, 8).Value = Cells(y, 8).Value + 5
If Cells(y, 21).Value >= 0.98 * Cells(13, 11).Value Then
' almost there.
Exit Do
End If
Loop
Do While Cells(y, 6).Value >= Cells(7, 5).Value
Cells(y, 8).Value = Cells(y, 8).Value + 0.1
If Cells(y, 21).Value >= Cells(13, 11).Value Then
Cells(y, 21).Value = Cells(y, 21).Value
' Rated power is achieved.
Exit Do
End If
Loop
If Cells(y, 21).Value >= Cells(14, 11).Value Then
Cells(y, 8).Value = Cells(y, 8).Value
ElseIf Cells(y, 21).Value < Cells(14, 11).Value Then
Cells(y, 8).Value = 0
End If
Next y
End Sub
Thanks,
jerry from Malaysia.
Sorry for my bad english.
Bookmarks