VBA - Bug in MsgBox on Mac

Lionel F 1 Reputation point
2022-10-30T08:23:32.267+00:00

Hello,

I have the latest version of Excel for Mac (16.66.1). I'm facing a bug illustrated by the following examples. What is very strange is that when the variable d is an Integer or a Long, the error does not occur.

The same macros run perfectly on a PC.

Is there a solution or should I wait for an update of Excel?

Thank you.

Option Explicit  
  
Sub test()  
   Dim msg     As String  
   Dim result  As VbMsgBoxResult  
   Dim d       As Double  
  
   d = 22  
   msg = "The value of d is " & d & "."  
   result = MsgBox(prompt:=msg, Buttons:=vbOKCancel)  
   d = d + 1   'Run-time error '6': Overflow  
End Sub  
  
'This time with a backup of d  
Sub test2()  
   Dim msg      As String  
   Dim result   As VbMsgBoxResult  
   Dim d        As Double  
   Dim d_backup As Double  
  
   d = 22  
   d_backup = d  
   msg = "The value of d is " & d_backup & "."  
   result = MsgBox(prompt:=msg, Buttons:=vbOKCancel)  
   d = d + 1   'Run-time error '6': Overflow  
End Sub
{count} votes

1 answer

Sort by: Most helpful
  1. Lionel F 1 Reputation point
    2022-10-31T08:46:30.513+00:00

    Thank you for the answer.

    I've send a message through Excel. Now I'm going to wait an update.

    0 comments No comments