1

I've gotten a Run-Time Error 6 while running some code, and while debugging I started to take away parts of it, until I was left with this very, very simple code, and still got an error

Sub test()

Dim NumberTest As Double

NumberTest = 1 / 2

End Sub

Error happens on the third line when I step into the code. Anyone knows what could be causing it? I'm on Excel 2016 for Mac

6
  • Not sure. When I execute this code on my Windows machine with Excel 2013 I'm unable to reproduce the issue (i.e. not getting any errors). Commented Dec 4, 2018 at 20:14
  • 1
    @Luiz, Seen this: stackoverflow.com/questions/48583900/…? Try NumberTest = cdbl(1 / 2) or some other variant of the equation NumberTest = cdbl(1) / 2 (as per the link) and see if the error persists. Commented Dec 4, 2018 at 20:16
  • You're dividing two Integer literals. Try converting either (or both) to Double first, using the CDbl conversion function. Are you sure this minimal reproducible example is correctly representative of the actual problem? Real code seldom divides two integer literals like this (you'd conceivably have Const half As Double = 0.5 instead). Commented Dec 4, 2018 at 20:35
  • Alternatively, use Double literals. Does NumberTest = 1# / 2# still overflow? Commented Dec 4, 2018 at 20:38
  • None of those work, I still get the same error... Code runs normally on windows, but I need it to work on Mac Commented Dec 4, 2018 at 23:24

1 Answer 1

0

I am not able to reproduce the error in Excel version 16.21 (181210). Perhaps if you install updates the problem will be resolved.

To find which version of Excel you have, go to the Excel menu and choose About Excel. You should have version 16.16.4 or 16.16.5 if you have Office 2016. If you have Office 2019 you should have version 16.19 or 16.20. Insider Fast build is 16.21 (181210). If your version is not one of these, use the Help menu and choose Check for Updates. If your version is any 15.x version, checking for updates won't get you updates. You'll have to download a new copy of AutoUpdate from Microsoft.enter image description here

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

Comments

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.