Estoy programando en VBA y me está ocurriendo un problema con el consumo de memoria pues, en la lista de procesos de Windows, Excel llega a 66 MB antes del proceso, y luego crece a 1680 MB después del proceso.
Sub NEW_CED()
' Ctrl+Shift+C
'INICIA LAS VENTANAS
New_document.Show
Worksheets("BASE_CÉDULAS").Select
'ELIMINACIÓN DE FORMATO CONDICIONAL
Cells.FormatConditions.Delete
'INICIALIZACIÓN DE FILA
Rows("500:500").Select '500 es un número cualesquiera. Realmente, no importa
Selection.Insert Shift:=xlDown
'ASIGNACIÓN DE VALORES
With Worksheets("BASE_CÉDULAS")
.Range("A500").Value = New_document.documentNumber.Text
.Range("B500").Value = New_document.lastNames.Text + " " + New_document.names.Text
.Range("C500").Value = New_document.document.Text
.Range("D500").Value = New_document_2.expeditionCity.Text 'Este form se inicializa desde New_document
'ORDENAR Y FILTRAR
With .Sort
.SortFields.Clear
.SortFields.Add Key:=Range("A2:A12674"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
.SetRange Range("A1:AD12674")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'RE-APLICAR FORMATO CONDICIONAL
.Columns("A:D").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A1=$A2"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
.Cells.FormatConditions(1).StopIfTrue = False
'BUSCAR Y SELECCIONAR
.Columns(1).Find(What:=New_document.documentNumber.Text, _
After:=.Range("A1"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False).Select
End With
Unload New_document
Unload New_document_2
End Sub
Pongo todo el código porque ni siquiera entiendo porqué es tan alto el consumo. La mayor parte del código se basa en grabación de macro. Agradezco de antemano al que pueda ayudarme...
Especificaciones:
Windows 7 Home Basic (32 bits)
Intel Celeron CPU G1610 2.6 GHz
4.00 GB de RAM