macro lenta

17/07/2009 - 22:35 por fredy | Informe spam
buenas tardes

tengo una macro que sse mueve muy lento... haciendo el seguimientos con F8,
la parte que se aprecia mas lenta es :

If LM > 54.26 And LM <= 100 Then R = Cells(3, 4): G = Cells(4, 4): B =
Cells(5, 4): letra = 2
If LM > 100 And LM <= 200 Then R = Cells(3, 5): G = Cells(4, 5): B =
Cells(5, 5): letra = 0
If LM > 200 And LM <= 400 Then R = Cells(3, 6): G = Cells(4, 6): B =
Cells(5, 6): letra = 2
If LM > 400 And LM <= 800 Then R = Cells(3, 7): G = Cells(4, 7): B =
Cells(5, 7): letra = 2
If LM > 800 Then R = Cells(3, 8): G = Cells(4, 8): B = Cells(5, 8): letra = 2

Cells(J, i) = VOL
With Cells(J, i)

.Interior.Color = RGB(R, G, B)
.Font.ColorIndex = letra
End With


como se puede mejorar la ejecucion de esta macro?..

muchas gracias

Fredy
Anori, Colombia

Preguntas similare

Leer las respuestas

#1 fredy
18/07/2009 - 00:50 | Informe spam
hola
agregue la siguiente instruccion y mejora el proceso... claro que el
resultado del proceso solo se ve cuando termina todo el recorrido...

Application.ScreenUpdating = False

"fredy" wrote:

buenas tardes

tengo una macro que sse mueve muy lento... haciendo el seguimientos con F8,
la parte que se aprecia mas lenta es :

If LM > 54.26 And LM <= 100 Then R = Cells(3, 4): G = Cells(4, 4): B =
Cells(5, 4): letra = 2
If LM > 100 And LM <= 200 Then R = Cells(3, 5): G = Cells(4, 5): B =
Cells(5, 5): letra = 0
If LM > 200 And LM <= 400 Then R = Cells(3, 6): G = Cells(4, 6): B =
Cells(5, 6): letra = 2
If LM > 400 And LM <= 800 Then R = Cells(3, 7): G = Cells(4, 7): B =
Cells(5, 7): letra = 2
If LM > 800 Then R = Cells(3, 8): G = Cells(4, 8): B = Cells(5, 8): letra = 2

Cells(J, i) = VOL
With Cells(J, i)

.Interior.Color = RGB(R, G, B)
.Font.ColorIndex = letra
End With


como se puede mejorar la ejecucion de esta macro?..

muchas gracias

Fredy
Anori, Colombia



Respuesta Responder a este mensaje
#2 Héctor Miguel
18/07/2009 - 01:19 | Informe spam
hola, fredy !

congelar la actualizacion de la pantalla agiliza procesos que (re)seleccionan objetos y/o modifican formatos
(probablemente) podrias ademas probar cambiando esta parte de tu codigo:

If LM > 54.26 And LM <= 100 Then R = Cells(3, 4): G = Cells(4, 4): B = Cells(5, 4): Letra = 2
If LM > 100 And LM <= 200 Then R = Cells(3, 5): G = Cells(4, 5): B = Cells(5, 5): Letra = 0
If LM > 200 And LM <= 400 Then R = Cells(3, 6): G = Cells(4, 6): B = Cells(5, 6): Letra = 2
If LM > 400 And LM <= 800 Then R = Cells(3, 7): G = Cells(4, 7): B = Cells(5, 7): Letra = 2
If LM > 800 Then R = Cells(3, 8): G = Cells(4, 8): B = Cells(5, 8): Letra = 2

por esta otra:

Dim Col As Integer
Col = Evaluate("match(" & LM & ",{54.25,100,200,400,800}+0.01)") + 3
R = Cells(3, Col): G = Cells(4, Col): B = Cells(5, Col): Letra = 2 * -(Col <> 5)

OJO: la variable LM debe estar declarada como tipo de datos Single (o Variant por omision)

(claro que, reproducir tu modelo y entorno de trabajo de manera "precisa"... no se podria sin mas detalles)

saludos,
hector.

__ OP __
agregue la siguiente instruccion y mejora el proceso...
claro que el resultado del proceso solo se ve cuando termina todo el recorrido...
Application.ScreenUpdating = False

tengo una macro que sse mueve muy lento... haciendo el seguimientos con F8, la parte que se aprecia mas lenta es :

If LM > 54.26 And LM <= 100 Then R = Cells(3, 4): G = Cells(4, 4): B = Cells(5, 4): letra = 2
If LM > 100 And LM <= 200 Then R = Cells(3, 5): G = Cells(4, 5): B = Cells(5, 5): letra = 0
If LM > 200 And LM <= 400 Then R = Cells(3, 6): G = Cells(4, 6): B = Cells(5, 6): letra = 2
If LM > 400 And LM <= 800 Then R = Cells(3, 7): G = Cells(4, 7): B = Cells(5, 7): letra = 2
If LM > 800 Then R = Cells(3, 8): G = Cells(4, 8): B = Cells(5, 8): letra = 2

Cells(J, i) = VOL
With Cells(J, i)
.Interior.Color = RGB(R, G, B)
.Font.ColorIndex = letra
End With

como se puede mejorar la ejecucion de esta macro?..
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida