How to improve this macro to run faster

jerrybetie

New Member
Joined
May 20, 2013
Messages
1
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.


<code></code>

<code></code>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
' Current reservoir level above MOL
Do While Cells(y, 6).Value >= Cells(7, 5).Value
' Increment @ 10.
Cells(y, 8).Value = Cells(y, 8).Value + 10
If Cells(y, 21).Value >= 0.99 * 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
Exit Do
' Rated power is achieved.
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






I tried to attach the file here but failed to do so.


Thanks,

jerry from Malaysia.

Sorry for my bad english.
 
Last edited:
what do you want to do. what is your data (give extract of data). explain with ref. to extract data and also give how data reslt will look like. use random data for security reasons if necessary/
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top