I'm developing a Macro for VBA in Excel 2007
and there's a section which fills a ListBox with 11 columns. Sometimes when I call this method for refilling the info appears a message which says:
Se ha producido el error '7' en tiempo de ejecución: Memoria insuficiente
in english is something like:
There was an error '7' at Runtime: Insufficient memory
and the code points at this line of code:
vList = ws.Range("A2", ws.Range("A2").End(xlDown).End(xlToRight))
I assured to release memory by setting all the objects used on this Function to Nothing
this is my full code:
Function llenarDatosTabla()
Dim vList As Variant
Dim ws As Worksheet: Set ws = Worksheets("PRODXSISTDATA")
If (IsEmpty(ws.Range("A2").Value) = False) Then
vList = ws.Range("A2", ws.Range("A2").End(xlDown).End(xlToRight))
Me.ListBox1.List = vList
End If
Set vList = Nothing
Set ws = Nothing
End Function