1

I got a bizzare overflow message error with this code and I can't understand why. Could you please help ? I am using exactly the same code in another vba module and it works.

Dim tab_base As Variant
tab_base= Worksheets("Test").Range("A1:AL1492").Value

Thanks,

Ismail

1 Answer 1

3

You must have some invalid cells in the range. I suspect mostly some cells formatted as Date with a value that is either too large or negative.

To be on the safe side and get the numeric values independent of the format, use the recommended .Value2. So try

tab_base= Worksheets("Test").Range("A1:AL1492").Value2

Then you get everything in the array as either strings or numbers (for date: number). You can later convert numbers to dates if necessary, but you can also check them for errors before.

For example, before converting some cell to a date, something like this:

Dim d As Date
On Error Resume Next
d = tab_base(i, j)
if Err.Number <> 0 Then ' invalid date, this was a cell causing overflow

p.s.: check for example if Err.Number = 6, it means you really had a date overflow (thx Mat's)

Sign up to request clarification or add additional context in comments.

1 Comment

Technically that comment is only valid when Err.Number = 6 ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.