I am writing a solution in Excel that uses several related forms of data entry. To move between the sequence of forms, the user can click the Previous or Next button. The current form is unloaded, and the new one is loaded and opened.
Sub NextForm(curForm As MSForms.UserForm, strFormName As String)
Dim intCurPos As Integer
Dim strNewForm As String
Dim newForm As Object
intCurPos = WorksheetFunction.Match(strFormName, Range("SYS.formlist"), 0)
If intCurPos = WorksheetFunction.CountA(Range("SYS.formlist")) Then
Debug.Print "No"
Else
Unload curForm
strNewForm = WorksheetFunction.Index(Range("SYS.formlist"), intCurPos + 1)
Set newForm = VBA.UserForms.Add(strNewForm)
newForm.Show
End Sub
The code as is allows you to add new forms to the sequence at any time through editing the "SYS.formlist" range.
One of the problems I noticed is that even after unloading the current form, it still remains in the VBA.Userforms collection. I assume this is because this code was called from this user form.
VBA.Userforms? , , , , excel .
Cheers,