Just got this error, which is really weird. The code worked fine before, now it doesn't. I tried to restart Excel but got the same error. This is the part of the code that produces the error:
Dim EmpRes as Worksheet
Set EmpRes = Worksheets("EmpRes")
Dim ER() As Variant
ER = EmpRes.Range("Q1").CurrentRegion ' <- This line is the cause of the Overflow error
The sheet EmpRes is empty when you run the code. Data in another sheet is then autofiltered and copied into it. In total there's 518 rows and 36 columns in the sheet when the error occurs.
If I change it to:
ER = EmpRes.Range("A1:C5")
it works. But
ER = EmpRes.Range("A1:C100")
doesn't.
Anyone knows why this might be? /Jens
Debug.Print EmpRes.Range("Q1").CurrentRegion.Addressbefore the problem line to see what the current region is. Also, to load things into an array, you could just declareERas a simpleVariant(so just useDim ER As Variantrather thanER()) and then just useER = EmpRes.Range("Q1").CurrentRegion.Value(once you make sure that this range is what you think it is).Debug.Print EmpRes.Range("Q1").CurrentRegion.Addressprinted$A$1:$AJ$518So no error there. It's around 18000 cells, is that a lot? Some rows contain strings, two contain dates, some contain integers and some are empty.ER()toERdidn't help. Tried with and without.value