ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Splitting a Procedure (https://www.excelbanter.com/excel-programming/275325-re-splitting-procedure.html)

John Wilson

Splitting a Procedure
 
Mark,

That's a lot of tedious typing that you did.

Along with what Steve gave you regarding shortening the
actual lines of code, you can split this up into separate
(smaller) subs in this fashion:

What you have now:
Case1
' lots of code
Case2
'lots of code
Case3
'lots of code
' etc.

What you can do:
Create a new sub named "Sub myCase0()"
Into that sub, move all of the Case0 code.
Create another sub named "Sub myCase1()"
Into that sub, move all of the Case1 code.
Do the same for the rest of the Cases

Now, in your main sub just call those other subs:
e.g.

Private Sub Up1_Click()
Select Case LB1.ListIndex
Case 0 'First item in list
myCase0
Case1
myCase1
'etc.

John

Mark wrote:

When I run the code below I get a compile error message
that states procedure to large. The knowledge base tells
me to split the procedure. How do i do this? Here is the
procedure below. Any suggestions or help is extremely
appreciated.




All times are GMT +1. The time now is 05:08 PM.

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