0

My procedure has become too large and won't run anymore. I've redesigned my code in my mind, but I need to get my current code up and running before I start editing. I've looked online and they say you need to split your procedure into subs and call them, but none really explain or show how you do this.

Thanks!

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
CustomX
  • 9,948
  • 30
  • 85
  • 115

3 Answers3

2
Sub Sub1()
    ' Code...
End Sub

Sub Sub2()
    ' Code...
End Sub

Sub Main()
    Sub1
    Sub2
End Sub
Chris Trombley
  • 2,232
  • 1
  • 17
  • 24
2

The first step is to take parts of code that are duplicated, and created one subroutine or function that you put that part into. Then you call the subroutine or function instead of duplicating the code everytime you need it.

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
0
Sub MacroName

Call ProcedureName1
Call ProcedureName2
etc...

End Sub

Sub ProcedureName1
'insert your vba code here

End Sub

The Call statement pulled each of the subs as long as I called the correct named sub.

Dharman
  • 30,962
  • 25
  • 85
  • 135