0

Well after writing a big big code and running it I got the message

Procedure too large.

After some researches I found that i can write the code this way :

Sub mycode()
Call proc1
Call proc2
Call proc3
End sub

Sub proc1()
'the code
End sub

Sub proc2()
'the code
End sub

Sub proc3()
'the code
End sub

And that's exactly what I've done but unfortunately only PROC1 code that is being executed.

How can I do to run the whole code : PROC1 then PROC2 then PROC3 ????

litelite
  • 2,857
  • 4
  • 23
  • 33
MissMacro
  • 31
  • 1
  • 1
  • 6
  • 1
    If you are calling proc 1/2/3 from mycode it will run. are you sure there isn't something else wrong in your code? – DragonSamu Aug 03 '16 at 10:09
  • 1
    Do you have lots of lines like ` ActiveWindow.ScrollRow = 9838`? I'd advise looking at the accepted answer on this thread: http://stackoverflow.com/questions/11450232/getting-error-procedure-too-large-in-vba-macros-excel – Darren Bartrup-Cook Aug 03 '16 at 10:13

1 Answers1

3

You must have the End keyword somewhere in proc1:

'// some code here
'// some more code
End

Replace this with:

'// some code here
'// some more code
Exit Sub

which will return control to the calling procedure.


The End word on it's own will stop execution without returning control to the calling procedure and shouldn't really be used unless there is good reason.

As a side note, there is no need to use the Call keyword in VBA it's just there for legacy purposes.

SierraOscar
  • 17,507
  • 6
  • 40
  • 68