VBA form not being recognised by the code

Chris_Hed

New Member
Joined
Feb 2, 2025
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I've searched this forum and others without success solving this weird problem. It might be an Excel bug, but I'm hoping it's just something I'm doing wrong.

My fairly basic spreadsheet has two userforms. One works perfectly well but the other won't even load. It did when I first created it but now isn't recognised by the code.

Observed behaviour:
  • The form appears to be correct in design and code windows (VBA editor)
  • Form name appears to be recognised in the code because capitalisation "errors" are automatically corrected.
  • Load(userform2) throws error 424 (object required). When hovering over the line in debug mode, it shows userform2 = <Object variable or With block variable not set>
  • Set Frm = userform2 throws error 424 (object required). When hovering over the line in debug mode, it shows userform2 = <Object variable or With block variable not set>
  • Dim Frm as New userform2 throws error 424 as well.
Things I've tried:
  • exporting then importing the userform
  • saving the excel sheet as a new file
  • disabling then re-enabling the macros
  • removing and reauthorising trusted locations and documents.
  • repairing Office 365 (short and long versions)
I'm really running out of ideas on this one so all suggestions welcome :-)
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Sounds like you have a variable named userform2 within your project. Find that variable and change its name.

Also, if the following works, it means it is probably the above variable naming issue :
VBA Code:
VBA.UserForms.Add("UserForm2").Show
 
Upvote 0
Sounds like you have a variable named userform2 within your project. Find that variable and change its name.

Also, if the following works, it means it is probably the above variable naming issue :
VBA Code:
VBA.UserForms.Add("UserForm2").Show
Thanks for taking the time to reply.

I should have also listed that I tried renaming the userform as well without success. I'm certain that there is no variable by any of those names in the project (the form name is actually frm_NewIncident, so pretty hard to use without noticing).

I tried the code you suggested and got the same error 424 (object required) highlighting that line of code. In debu mode there was no mouseover text.
 
Upvote 0
OK, more troubleshooting and a little more info.

When importing the exported file into a brand new workbook, the behaviour followed it. The other (working) form imported and worked just fine.

It seems to be something specific to the form and I might just need to accept remaking it from scratch :(
 
Upvote 0

Forum statistics

Threads
1,226,117
Messages
6,189,061
Members
453,524
Latest member
AshJames

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top