Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3306232
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:15:51+00:00 2026-05-17T21:15:51+00:00

I am writing a solution in Excel that uses a number of linked data

  • 0

I am writing a solution in Excel that uses a number of linked data entry forms. To move between he sequence of forms, the user can click a “Previous” or “Next button. The current form is unloaded and the new one 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 new forms to be added into the sequence at any time through the editing of the range “SYS.formlist”.

One problem I have noticed is that even after the current form is unloaded, it still remains in the VBA.Userforms collection. I would presume this is because this code has been called from that userform.

Is there a way to force the removal of that form from the VBA.Userforms collection? What is occuring is that if the user moves forward and then back, two copies of the form appear in memory and and excel throws exceptions about two modal forms being open.

Cheers,
Nick

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:15:51+00:00Added an answer on May 17, 2026 at 9:15 pm

    The answer was (sadly) quite simple and inspired by bugtussle’s answer.

    The subroutine was passing the curForm variable as an MSForms.Userform object, but the form is held in memory as its own object type. (As an example, you can access a form through Set form = new formName)

    So by changing the curForm paramater type to Variant, it will pass the actual object through rather than a copy of the object. Unload was only unloading the copy, not the actual object.

    Thanks bugtussle!

    So, corrected code is:

    Sub NextForm(curForm As Variant, 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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a solution for a user that matches a list of phone
I'm writing a solution around MOSS 2007. And storing fairly large quantities of data
I'm tasked with writing a solution for fixing a poorly performing legacy excel file
I'm writing a solution where I use some configuration files that should be editable
Before I embark on writing my own solution to this issue, can anyone point
I am currently writing a Sharepoint Workflow that is activated when a user saves
I'm writing a solution where the data entities are passed to clients using datasets
I am writing an NServiceBus solution and trying to use DBSubcriptionStorage. This uses NHibernate
I'm writing a solution for the Usaco problem Electric Fences. In the problem you
Is BIND DNS + DLZ reliable? scalable? Is it a better solution than writing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.