Compile Error: Procedure too large

C

Corey ....

I am using the:
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
routine to run a series of macro's, but not i get the 'Too large error'.

I was thinking if i break up the code and place it into various Modules, and
using a 'Call" procedure to run the macro with this procedure instead.

However when i tried this it does not run.

Can i remove the 'Private' and use a 'Public' to get it to work?
 
B

Bob Phillips

You cannot put any userform events into any module other than the userform
module. What you have to do is extract parts of the code out into separate
procedures that you call from the event code, and put those procedures into
standard code modules.


Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

'some standard userform, stuff

'now call a procedure passing the form as an objec variable

Call DoStuff(tHisForm:=Me)

'repeat this for discrete functional blocks
End Sub


in a standard code module

PUBLIC DoStuff(ByRef ThisForm as Object)

With ThisForm

...

End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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