I've been building a system that will keep track of student grades, using Excel. I've coded it under Windows, where everything works fine, but when I test it on the Mac version of Excel (the latest version, 15.24, I believe), the InputBoxes only show the title and the text box for the input data; the prompt text is not shown. Here is an example of the code that I use to handle the InputBoxes:
On Error Resume Next
assessmentName = Application.InputBox("Please enter a name for the new assessment:", "Enter assessment name")
If assessmentName = "False" Then
Exit Sub
End If
Err.Clear
In this case, all that is displayed is the title 'Enter assessment name' and the text box where the user types the name. Is there a difference in the way the Mac version of Excel deals with VBA code, that would cause this to happen? Are the problems a result of bad coding on my part, combined with the weaker VBA support that Excel seems to have on the Mac?
UPDATE: I've now labelled the arguments in the code like so:
On Error Resume Next
assessmentName = Application.InputBox( _
Prompt:="Please enter a name for the new assessment:", _
Title:="Enter assessment name")
If assessmentName = "False" Then
Exit Sub
End If
Err.Clear
Unfortunately, the prompt is still missing when I run the macro on the Mac version of Excel.
SECOND UPDATE: I've found the solution and posted it in an answer below.
I've found the answer, and am posting it here in the hope of helping somebody else who's having the same problem. When I was reading this page I found the following comment:
Microsoft seems to love confusion, so you also have access to the InputBox method, which is a method of the Application object.
So it turns out that I was using Application.InputBox, when I should have been using simply InputBox.
The following code works, i.e. it displays the prompt as well as the input box and title:
On Error Resume Next
assessmentName = InputBox( _
Prompt:="Please enter a name for the new assessment:", _
Title:="Enter assessment name")
If assessmentName = "False" Then
Exit Sub
End If
Err.Clear
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With