Loading Userform Errors 1004

G

Guest

I have this file that has only 1 generic userform had been loading upon
clicking a commandbutton. The command buttons are generically called
commandbutton1 on 12 different worksheets and are such:

Private Sub CommandButton1_Click()
loadform
End Sub

sub Loadform is located in module 1 and goes like this:

Sub loadform()
Load UserForm1
UserForm1.Show
End Sub

When I say generic, I mean that I just save the old one as a new file name
and clear out some values in some cells. However, I am now getting an error
message that reads that there is a runtime error 1004 due to
application-defined or object-defined error. This should be a very simple
yet stupid thing that I am overseeing. I haven't not changed the code for
the userform initialization and when I go back to the files created in the
prior months, I do not run into this problem. Is it possible the file and/or
userform has gotten corrupted as it is often operated in Share mode?
 
G

Guest

Run the UserForm_Initialize procedure directly from the UF code module and
see if it selects the code causing the error.

Regards,
Greg
 
G

Guest

Greg;

just a thought. if the name of the userform is Userform1, then shouldn't
the procedure be called Userform_Initialize?
 
G

Guest

If the name of the UF is UserForm1 then the event procedure should still be
called UserForm_Initialize if that's what you were asking.

What I meant by my suggestion is that if you run the Initialize (or
Activate) code from within the UF's code module it will typically highlight
the offending code. In contrast, showing it with a UserForm1.Show command
from a outside procedure will typically only return the error description.

1. From within the VBE right click the UF
2. Select View Code
3. Place the cursor anywhere inside the UserForm_Initialize procedure and
click the Continue button (little blue triangle on its side) on the VBE's
Standard toolbar.

Greg
 
G

Guest

Greg;

thanks. did it and found the culprit of my problems. it wasn't the Load
command but rather the Initialization as you had pointed out. My range
references were no longer valid. Thanks for the help.

Steven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top