Hi all!
Without further adue, here's the code:
The Overflow error occurs when it reaches the 4th worksheet. The yellowed line is the "w = Z / x" one. The values there would be Z = 4700 and x = 9305.
Nothing to overflow about, theoretically !
By the way, when I don't loop through worksheets and only run my code for the cell at which it gives me an error, it works.
Any idea?
(Edit: I know variant isn't a great variable type here, I was going with Long or double but everything gives an error)
(Edit2: I did some more testing and for some reason my Z and x both are considered as 0. It explains why the overflow, but I still don't know why the values are suddenly not taken into account)
(Edit3: I'm the dumbest person there is. I had a hidden worksheet. With zeros on.)
Without further adue, here's the code:
Code:
Sub lalala()
Dim x As Variant, Z As Variant, w As Variant
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
For y = 15 To 17
x = ws.Cells(3, y) + ws.Cells(2, y)
Z = 100 * ws.Cells(3, y)
w = Z / x
ws.Cells(4, y) = w
Next y
Next ws
End Sub
The Overflow error occurs when it reaches the 4th worksheet. The yellowed line is the "w = Z / x" one. The values there would be Z = 4700 and x = 9305.
Nothing to overflow about, theoretically !
By the way, when I don't loop through worksheets and only run my code for the cell at which it gives me an error, it works.
Any idea?
(Edit: I know variant isn't a great variable type here, I was going with Long or double but everything gives an error)
(Edit2: I did some more testing and for some reason my Z and x both are considered as 0. It explains why the overflow, but I still don't know why the values are suddenly not taken into account)
(Edit3: I'm the dumbest person there is. I had a hidden worksheet. With zeros on.)
Last edited: