I have code in VBA and with large number of rows it use too much memory - it can take few GB and make crush. Code take number ask server for XLM find some data and write them than go to another number. If there is more than 500 rows it crush. Could you help me optimalize code to handle about 10 000 rows? Thank you for your help Marek
Sub ares()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False 'potlačí obnovování obrazovky
Application.DisplayAlerts = False 'potlačí varovné hlášky
Application.DisplayStatusBar = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Dim i As Integer
Dim row As Integer
Dim column As Integer
For i = 2 To 15000
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "ares"
Sheets("ares").Activate
On Error GoTo ErrorHandler
ActiveWorkbook.XmlImport URL:="http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi?ico=" & Worksheets("ico").Cells(i, 1).Value, ImportMap:=Nothing, Overwrite:=True, Destination:=Range("$A$1")
If Worksheets("ares").Cells(2, 10).Value = "" Then
Worksheets("ico").Cells(i, 2).Value = "OK"
row = 2
column = 3
Do While Worksheets("ares").Cells(row, 1).Value <> ""
If Worksheets("ares").Cells(row, 167).Value <> "" Then
Worksheets("ico").Cells(i, column).Value = Worksheets("ares").Cells(row, 167).Value
column = column + 1
End If
row = row + 1
Loop
Else
Worksheets("ico").Cells(i, 2).Value = Worksheets("ares").Cells(2, 10).Value
End If
ErrorResume:
Sheets("ares").Delete
Next i
Application.ScreenUpdating = True 'zapne obnovování obrazovky
Application.DisplayAlerts = FaTruelse 'obnoví varovné hlášky
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
Exit Sub
ErrorHandler:
Worksheets("ico").Cells(i, 2).Value = "Jiná chyba"
Resume ErrorResume
End Sub