1

My goal is to code manually a userForm with Excel VBA (2018 MacOS version).

Being a beginner and confirming the unavailability of inserting userform in Excel 2018 MacOS, I have started by a simple VBA script example from : https://excelmacromastery.com/vba-user-forms-1/#A_Modal_Example

' PROCEDURE CODE
Sub UseModal()

    ' Create and show form
    Dim frm As New UserFormFruit

    ' Display Userform - The code in this procedure
    ' will wait here until the form is closed
    frm.Show
    
    ' Display the returned value
    MsgBox "The user has selected " & frm.Fruit
        
    ' Close the form
    Unload frm
    Set frm = Nothing

End Sub

' USERFORM CODE
' Returns the textbox value to the calling procedure
Public Property Get Fruit() As Variant
    Fruit = textboxFruit.Value
End Property

But I get "type used not defined".

Here a screenshot of my project interface :

Screenshot of interface

I would like to know where is my error: how to define the type used?

(I am using Excel 2018 for MacOS).

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 3
    You need to create a user form called “UserFormFruit.” Right click in the project browser and add new user form. Then name it “UserFormFruit” – Bigbob556677 May 17 '18 at 22:01
  • @Philip556677 thanks for your answer. On Excell 2018 for MacOS version, adding userForm functionality is not available, I can only code directly the userForm, there is not UI designer, this comes from the following post : https://stackoverflow.com/questions/50399661/userform-with-excel-2018-for-macos . Adding user form functionality is available on Windows Excel 2018 version or Excel 2011 for MacOS version. Have I got other alternatives for the code of my question above ? –  May 17 '18 at 22:08
  • Other than coding the class manually. You may be able to use a designer tool and import the form to vba. – Bigbob556677 May 17 '18 at 22:10
  • Does a such designer tool exist in Pack Office ? –  May 17 '18 at 22:12
  • Coding the class manually : have you got a link or tutorial to acheive it ? –  May 17 '18 at 22:15
  • I have found maybe a begin of solution on https://stackoverflow.com/questions/26956591/excel-vba-add-code-userform-programmatically/27459772#27459772 but I don't know how to use this Public Function inside Visual Basic editor and execute it or include it into module ? any suggestion is welcome –  May 17 '18 at 23:14

0 Answers0