Pc to fast/slow or something like that...

R

Robert

Hello. I am experiencing some problems in my Excel visual basic
project.

The project exists contains two macro´s.

macro1: Processcalculate() which calculates my workbook evertime it´s
executed.
macro2: LabelChange() This macro´s checks if a cellvalue is true or
false. If true, the colour of the label changes.

The case:

Everytime that macro1 is executed the value in cell B14 ascends until
it reaches the value 1.20.
After this execution the value must be checked (macro2) whether it is
true or false and change the colour or do nothing.

These macros works perfect.

Now there is one thing. The hole project must be dynamic.

The user can hit a cmdbutton which starts the project (which is a
simulation of an emptying vessel. This is build up out of a lot of
labels [#86]. Changer the colour, one by one, makes it look like it is
emptying.

This is the code of the button:
______________________________________________________________
Private Sub Simulationstart_click()

Do Until Range("B14").Value > 1.2
Call ProcessCalculate
Call Labelchange
Loop

End Sub
______________________________________________________________
Sub ProcessCalculate()

N_0 = Cells(7, "K").Value
N_1 = Cells(6, "K").Value
N_2 = Cells(5, "K").Value
N_3 = Cells(4, "K").Value
N_4 = Cells(3, "K").Value

'=MAX($K$7-B17;0
H_0_0 = Application.WorksheetFunction.Max((N_0 - x_t_0), 0)
Cells(13, "C").Value = H_0_0

H_1_0 = Application.WorksheetFunction.Max((N_1 - x_t_0), 0)
Cells(13, "D").Value = H_1_0

H_2_0 = Application.WorksheetFunction.Max((N_2 - x_t_0), 0)
Cells(13, "E").Value = H_2_0

And lot´s more!!!
_________________________________________________
Sub Labelchange()

Dim y As Integer

For y = 1 To 86
If Range("B14").Value > (y / 86) * 1.2 Then
Me.Controls("Label" & CStr(y - 1)).BackColor = vbBlack
Me.Controls("Label" & CStr(y - 1)).BorderColor = vbBlack
End If
Next y

End Sub
______________________________________________________________

This seems to work almost.

The problem that seems to be happening is that after macro1 is
executed, it starts right again with macro1. like there isnt any time
to execute macro2. And then, at the end. when the value 1.2 is reached
all of the labels change their colors at once.

Does anyone has a suggestion to fix this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top