I can't imagine any code that can't be broken up into smaller subs.
Inside your long sub you should be able to find a stretch of code that can stand by itself. Just put all that code into a separate sub and call it from your main sub.
Sub Sub_1()
'Line 1
'Line 2
'etc.
'Line 39
If <sometest> then
'Line 41
'Line 42
'etc.
'Line 87
Else
'Line 89
'etc.
'line 107
End If
'More Lines
End Sub
Convert to:
Sub Sub_1()
'Line 1
'Line 2
'etc.
'Line 39
If <sometest> then
Sub_2
Else
Sub_3
End If
'More Lines
End Sub
Sub Sub_2
'Line 41
'Line 42
'etc.
'Line 87
End Sub
Sub Sub_3
'Line 89
'etc.
'line 107
End Sub
You'll probably need to pass parameters or make public variables or make Sub_2 and Sub_3 into functions. But it cant be done.
Bookmarks