Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Como mejorar el tiempo de ejecución para calcular el resultado de formulas en 26000 filas

publicado

Buenas Tardes:

Estoy tratando de realizar un ciclo que me calcule una formula para 26000 filas aproximadamente. He echo el intento con 3 ciclos distintos pero al ejecutar la macro se me colapsa el excel (No responde) y se demora mucho tiempo la ejecución. (Macro_1, Macro_2 y Macro_3)

Acudo a ustedes para que me guíen y me digan que error estoy cometiendo o cual puede ser la mejor forma de realizar el procedimiento.

De antemano muchas gracias.

Julio Cesar Sanguino L.

Option Explicit
Dim Fila, I As Long
Dim StarTime As Double
Dim Endtime As Double
Dim A As Integer


Sub Macro_1()

AgilizarExcel

StarTime = (Now - Int(Now)) * 24 'Tiempo Inicio


Fila = Cells(Rows.Count, "AS").End(xlUp).Offset(1, 0).Row

'Calcular formula y llevar valor a la celda

For I = 2 To Fila - 1

If Range("as" & I) = "Inactivo" Then
Range("ax" & I) = 0
Else
A = Application.WorksheetFunction.SumIf(Range("aw$1:aw" & I - 1), Range("Aw" & I), Range("ax$1:ax" & I - 1))
If A > 0 Then
Range("ax" & I) = 0
Else
Range("ax" & I) = 1
End If
End If
Next



Endtime = (Now - Int(Now)) * 24 'Tiempo Final
Range("BC1") = (Endtime - StarTime) * 60 'Tiempo de duracion de la macro

NormalizarExcel

End Sub

Sub Macro_2()

AgilizarExcel

StarTime = (Now - Int(Now)) * 24 'Tiempo Inicio

Fila = Cells(Rows.Count, "AS").End(xlUp).Offset(1, 0).Row

'Calcular formula y llevar valor a la celda

With Range("Ax2:Ax" & Fila - 1)
.Formula = "=IF(AS2=""Inactivo"",0,IF(SUMIF(aw$1:aw1,Aw2,ax$1:ax1)>0,0,1))"
.Value = .Value
End With

Endtime = (Now - Int(Now)) * 24 'Tiempo Final
Range("BH1") = (Endtime - StarTime) * 60 'Tiempo de duracion de la macro

NormalizarExcel

End Sub

Sub Macro_3()

AgilizarExcel
StarTime = (Now - Int(Now)) * 24 'Tiempo Inicio

Dim Mestadisticas() As Long
Dim B As Integer
Dim Z, X As Integer
Fila = Cells(Rows.Count, "AS").End(xlUp).Offset(1, 0).Row

ReDim Mestadisticas(Fila - 1)

Range("i2").Select
A = 2
B = 1

For A = 2 To Fila - 1
Z = Application.WorksheetFunction.SumIf(Range("aw$1:aw" & A - 1), Range("Aw" & A), Range("ax$1:ax" & A - 1))
'"=IF(AS2=""Inactivo"",0,IF(SUMIF(aw$1:aw1,Aw2,ax$1:ax1)>0,0,1))"

If Range("aS2") = "Inactivo" Then
Mestadisticas( = 0
Else
If Z > 0 Then
Mestadisticas( = 0
Else
Mestadisticas( = 1
End If
End If

B = B + 1
Next


Range("AX2").Select
Range("AX2:AX" & Fila - 1).Value = Application.WorksheetFunction.Transpose(Mestadisticas)

Endtime = (Now - Int(Now)) * 24 'Tiempo Final
Range("BK1") = (Endtime - StarTime) * 60 'Tiempo de duracion de la macro

NormalizarExcel

End Sub

Sub AgilizarExcel()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False

End Sub

Sub NormalizarExcel()

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
Application.CutCopyMode = False

End Sub[/PHP]

Featured Replies

No hay posts para mostrar

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.