ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile Error: Procedure too large (https://www.excelbanter.com/excel-programming/414592-compile-error-procedure-too-large.html)

Corey ....[_2_]

Compile Error: Procedure too large
 
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?



Bob Phillips

Compile Error: Procedure too large
 
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)

"Corey ...." wrote in message
...
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?





All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com