0

I have the following code where I pick a value from a named range and store it in a variable declared as a Double. Later on, after changing the variable or not I want to reassign it to the named range. But here I get an Overflow error. The error disappears if I change the variable into an Integer. For information, I am working on a Mac.

'''

Dim maxDepth As Double
i=0

Do Until Range("scopeID").offset(i, 0) = ""
    maxDepth = Range("currentDepth").offset(i, 0)

    ' some code here that possibly changes the value based on some conditions

    Range("currentDepth").offset(i, 0) = maxDepth
    i = i + 1
Loop

'''

PierreEH
  • 21
  • 3
  • I don't have the time to test this but try the explicit ```Value2``` property rather than the implicit ```Value```. So, replace all three occurrences of ```.offset(i, 0)``` with ```.offset(i, 0).Value2``` and see if that works. Quick read on the differences [here](https://stackoverflow.com/a/17363466/8488913) – Cristian Buse May 04 '22 at 10:30
  • Not sure anyone can tell without knowing what the rest of your code does. – SJR May 04 '22 at 11:05
  • 1
    I assume you don't have the overflow because of the double but because of `i` overflowing. – FunThomas May 04 '22 at 12:48

0 Answers0