Excel file freezes and stop working, file size 1GB

ibmy

Board Regular
Joined
Mar 4, 2020
Messages
134
Office Version
  1. 2016
Platform
  1. Windows
Hi,

My Excel file freezes,stop working and took a very long time (15 minutes) to finish when apply the formula in G3 to the last row then loop next column.

3.1.xlsb
CDEFGHIJKLMNOPQRSTU
1Point A1.207021.207031.207061.206991.207241.207071.20711.207121.207111.207131.207151.207141.207041.207231.20727
21.20721
31.20722               
41.20723
51.20724
61.20721
71.20724
81.20722
91.20722
101.20723
111.20722
121.20723
131.20722
141.20722
151.20729
161.20732
171.20722
181.20723
191.20722
201.20722
211.20719
Sheet9
Cell Formulas
RangeFormula
G3:U3G3=IF(OR(AND($C2>G$1,$C3<G$1),AND($C2<G$1,$C3>G$1)),1,"")

Last Row is based on column C & Last Column is based on last column used in row 1.
Both Last Row and Last Column have no fix number, it vary daily data.
Last Column could be in range of 1000-2500 while Last Row could be 250k to 550k

Can formula in G3 can be converted to vba code?
...then fill down G3 to last row, loop until last column

p/s: My Excel file size change from 15MB to 1GB after apply the formula and cannot be open.

1GB file size.png
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Delete all the formulae and try this macro:
VBA Code:
Sub CalcVals()
    Application.ScreenUpdating = False
    Dim v As Variant, r As Long, c As Long, lRow As Long, lCol As Long, arr() As Variant
    lRow = Range("C" & Rows.Count).End(xlUp).Row
    lCol = Cells(1, Columns.Count).End(xlToLeft).Column
    v = Range("C1:C" & lRow).Resize(, lCol - 2).Value
    ReDim arr(lRow - 2, UBound(v, 2) - 4)
    For r = 3 To UBound(v)
        For c = 5 To UBound(v, 2)
            If (v(r - 1, 1) > v(1, c) And v(r, 1) < v(1, c)) Or (v(r - 1, 1) < v(1, c) And v(r, 1) > v(1, c)) Then
                arr(r - 3, c - 5) = "1"
            Else
                arr(r - 3, c - 5) = ""
            End If
        Next c
    Next r
    Range("G3").Resize(lRow - 2, UBound(v, 2) - 4) = arr
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
Thanks @mumps

It works but for large data, there is an error

Daily Data: daily
Row : 120k , Column : ANH
It took 20 minutes
Need to close all others program, else there is memory error.

Weekly Data : weekly
Row : 500k , Column : CFE
Error :
Error 7 - Out Of Memory.png


My system spec:
system spec.png


Is there any way to get the result faster for daily data or do I need to upgrade RAM?
....or do I need to use other programs that faster data processing? If so. please recommend me...
 
Upvote 0
You have a huge amount of data. The approach I used places all your data in memory and analyses it in memory without having to reference the sheet so it is very fast. I'm not sure about another program (perhaps a database like Microsoft Access?) Upgrading your RAM and a faster processor may help although I don't know to what extent you would have to upgrade but given the amount of data you have, I suspect that the time factor may continue to be a problem. Perhaps other members of this Forum will have other suggestions.
 
Upvote 0
Perhaps break your 1 gb workbook down into smaller sizes and analyze each segment by itself. From my experience, 1 gb is practically unmanageable for Excel to handle.
 
Upvote 0

Forum statistics

Threads
1,224,812
Messages
6,181,089
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top