How to reference a UserForm within Excel VBA Macro


  • I am replacing an older vba module that uses DialogSheets with the newer UserForms. Referencing the old style DialogSheets, worked something like this:

        Workbooks("Code").DialogSheets("AddSheetUserForm").EditBoxes("edit box 10").Text

    which does not work, furthermore there is no "EditBox" tool available.

    Seems like the reference should be:


    Any suggestions apprecated.

    • Moved by kleinma Wednesday, May 09, 2012 2:38 PM VBA question (From:Visual Basic Language)
    Wednesday, May 09, 2012 12:28 AM

All replies

  • ' set the userform caption
    AddSheetUserForm.Caption = "Add Sheet User Form"
    ' change the text in a a text box on user form AddSheetUserForm
    AddSheetUserForm.EditBox10.Text = "I added something here"
    Debug.Print AddSheetUserForm.Caption, AddSheetUserForm.EditBox10.Text

    Ed Ferrero

    Friday, May 18, 2012 7:24 AM